mirror of
https://github.com/ansible/awx.git
synced 2026-01-26 16:11:30 -03:30
Updating tests, changing 'method' to 'http_method'
This commit is contained in:
parent
cc0310ccd4
commit
6e9f74eb17
@ -23,8 +23,8 @@ class WebhookBackend(AWXBaseEmailBackend):
|
||||
recipient_parameter = "url"
|
||||
sender_parameter = None
|
||||
|
||||
def __init__(self, headers, method, disable_ssl_verification=False, fail_silently=False, username=None, password=None, **kwargs):
|
||||
self.method = method
|
||||
def __init__(self, headers, http_method, disable_ssl_verification=False, fail_silently=False, username=None, password=None, **kwargs):
|
||||
self.http_method = http_method
|
||||
self.disable_ssl_verification = disable_ssl_verification
|
||||
self.headers = headers
|
||||
self.username = username
|
||||
@ -38,9 +38,9 @@ class WebhookBackend(AWXBaseEmailBackend):
|
||||
sent_messages = 0
|
||||
if 'User-Agent' not in self.headers:
|
||||
self.headers['User-Agent'] = "Tower {}".format(get_awx_version())
|
||||
if self.method.lower() not in ('put', 'post'):
|
||||
raise ValueError("Method must be either 'POST' or 'PUT'.")
|
||||
chosen_method = getattr(requests, self.method.lower(), None)
|
||||
if self.http_method.lower() not in ('put', 'post'):
|
||||
raise ValueError("HTTP method must be either 'POST' or 'PUT'.")
|
||||
chosen_method = getattr(requests, self.http_method.lower(), None)
|
||||
for m in messages:
|
||||
if chosen_method is not None:
|
||||
r = chosen_method("{}".format(m.recipients()[0]),
|
||||
|
||||
@ -117,7 +117,7 @@ def mk_credential(name, credential_type='ssh', persisted=True):
|
||||
def mk_notification_template(name, notification_type='webhook', configuration=None, organization=None, persisted=True):
|
||||
nt = NotificationTemplate(name=name)
|
||||
nt.notification_type = notification_type
|
||||
nt.notification_configuration = configuration or dict(url="http://localhost", headers={"Test": "Header"})
|
||||
nt.notification_configuration = configuration or dict(url="http://localhost", username="", password="", headers={"Test": "Header"})
|
||||
|
||||
if organization is not None:
|
||||
nt.organization = organization
|
||||
@ -216,7 +216,7 @@ def mk_workflow_job_template(name, extra_vars='', spec=None, organization=None,
|
||||
|
||||
|
||||
def mk_workflow_job_template_node(workflow_job_template=None,
|
||||
unified_job_template=None,
|
||||
unified_job_template=None,
|
||||
success_nodes=None,
|
||||
failure_nodes=None,
|
||||
always_nodes=None,
|
||||
@ -231,11 +231,11 @@ def mk_workflow_job_template_node(workflow_job_template=None,
|
||||
return workflow_node
|
||||
|
||||
|
||||
def mk_workflow_job_node(unified_job_template=None,
|
||||
def mk_workflow_job_node(unified_job_template=None,
|
||||
success_nodes=None,
|
||||
failure_nodes=None,
|
||||
always_nodes=None,
|
||||
workflow_job=None,
|
||||
workflow_job=None,
|
||||
job=None,
|
||||
persisted=True):
|
||||
workflow_node = WorkflowJobNode(unified_job_template=unified_job_template,
|
||||
@ -247,4 +247,3 @@ def mk_workflow_job_node(unified_job_template=None,
|
||||
if persisted:
|
||||
workflow_node.save()
|
||||
return workflow_node
|
||||
|
||||
|
||||
@ -385,7 +385,9 @@ def notification_template(organization):
|
||||
organization=organization,
|
||||
notification_type="webhook",
|
||||
notification_configuration=dict(url="http://localhost",
|
||||
headers={"Test": "Header"}))
|
||||
username="",
|
||||
password="",
|
||||
headers={"Test": "Header",}))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@ -92,7 +92,7 @@ def test_inherited_notification_templates(get, post, user, organization, project
|
||||
isrc.save()
|
||||
jt = JobTemplate.objects.create(name='test', inventory=i, project=project, playbook='debug.yml')
|
||||
jt.save()
|
||||
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_notification_template_simple_patch(patch, notification_template, admin):
|
||||
@ -124,7 +124,7 @@ def test_custom_environment_injection(post, user, organization):
|
||||
organization=organization.id,
|
||||
notification_type="webhook",
|
||||
notification_configuration=dict(url="https://example.org", disable_ssl_verification=False,
|
||||
headers={"Test": "Header"})),
|
||||
http_method="POST", headers={"Test": "Header"})),
|
||||
u)
|
||||
assert response.status_code == 201
|
||||
template = NotificationTemplate.objects.get(pk=response.data['id'])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user