From 30741e762a088d21ab13256882e7c0c499aa2aff Mon Sep 17 00:00:00 2001 From: beeankha Date: Thu, 6 Jun 2019 15:26:00 -0400 Subject: [PATCH] Add more notification tests --- .../functional/api/test_notifications.py | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/awx/main/tests/functional/api/test_notifications.py b/awx/main/tests/functional/api/test_notifications.py index d3cd3ca637..d211026b07 100644 --- a/awx/main/tests/functional/api/test_notifications.py +++ b/awx/main/tests/functional/api/test_notifications.py @@ -3,6 +3,69 @@ import pytest from awx.api.versioning import reverse +@pytest.mark.django_db +def test_get_org_running_notification(get, admin, organization): + url = reverse('api:organization_notification_templates_started_list', kwargs={'pk': organization.pk}) + response = get(url, admin) + assert response.status_code == 200 + assert len(response.data['results']) == 0 + + +@pytest.mark.django_db +def test_post_org_running_notification(get, post, admin, notification_template, organization): + url = reverse('api:organization_notification_templates_started_list', kwargs={'pk': organization.pk}) + response = post(url, + dict(id=notification_template.id, + associate=True), + admin) + assert response.status_code == 204 + response = get(url, admin) + assert response.status_code == 200 + assert len(response.data['results']) == 1 + + +@pytest.mark.django_db +def test_get_project_running_notification(get, admin, project): + url = reverse('api:project_notification_templates_started_list', kwargs={'pk': project.pk}) + response = get(url, admin) + assert response.status_code == 200 + assert len(response.data['results']) == 0 + + +@pytest.mark.django_db +def test_post_project_running_notification(get, post, admin, notification_template, project): + url = reverse('api:project_notification_templates_started_list', kwargs={'pk': project.pk}) + response = post(url, + dict(id=notification_template.id, + associate=True), + admin) + assert response.status_code == 204 + response = get(url, admin) + assert response.status_code == 200 + assert len(response.data['results']) == 1 + + +@pytest.mark.django_db +def test_get_inv_src_running_notification(get, admin, inventory_source): + url = reverse('api:inventory_source_notification_templates_started_list', kwargs={'pk': inventory_source.pk}) + response = get(url, admin) + assert response.status_code == 200 + assert len(response.data['results']) == 0 + + +@pytest.mark.django_db +def test_post_inv_src_running_notification(get, post, admin, notification_template, inventory_source): + url = reverse('api:inventory_source_notification_templates_started_list', kwargs={'pk': inventory_source.pk}) + response = post(url, + dict(id=notification_template.id, + associate=True), + admin) + assert response.status_code == 204 + response = get(url, admin) + assert response.status_code == 200 + assert len(response.data['results']) == 1 + + @pytest.mark.django_db def test_get_jt_running_notification(get, admin, job_template): url = reverse('api:job_template_notification_templates_started_list', kwargs={'pk': job_template.pk}) @@ -22,3 +85,45 @@ def test_post_jt_running_notification(get, post, admin, notification_template, j response = get(url, admin) assert response.status_code == 200 assert len(response.data['results']) == 1 + + +@pytest.mark.django_db +def test_get_sys_jt_running_notification(get, admin, system_job_template): + url = reverse('api:system_job_template_notification_templates_started_list', kwargs={'pk': system_job_template.pk}) + response = get(url, admin) + assert response.status_code == 200 + assert len(response.data['results']) == 0 + + +@pytest.mark.django_db +def test_post_sys_jt_running_notification(get, post, admin, notification_template, system_job_template): + url = reverse('api:system_job_template_notification_templates_started_list', kwargs={'pk': system_job_template.pk}) + response = post(url, + dict(id=notification_template.id, + associate=True), + admin) + assert response.status_code == 204 + response = get(url, admin) + assert response.status_code == 200 + assert len(response.data['results']) == 1 + + +@pytest.mark.django_db +def test_get_wfjt_running_notification(get, admin, workflow_job_template): + url = reverse('api:workflow_job_template_notification_templates_started_list', kwargs={'pk': workflow_job_template.pk}) + response = get(url, admin) + assert response.status_code == 200 + assert len(response.data['results']) == 0 + + +@pytest.mark.django_db +def test_post_wfjt_running_notification(get, post, admin, notification_template, workflow_job_template): + url = reverse('api:workflow_job_template_notification_templates_started_list', kwargs={'pk': workflow_job_template.pk}) + response = post(url, + dict(id=notification_template.id, + associate=True), + admin) + assert response.status_code == 204 + response = get(url, admin) + assert response.status_code == 200 + assert len(response.data['results']) == 1