mirror of
https://github.com/ansible/awx.git
synced 2026-01-15 11:50:42 -03:30
Add api test, edit AWX docs
This commit is contained in:
parent
9cfed6f2a8
commit
7687eddf6d
24
awx/main/tests/functional/api/test_notifications.py
Normal file
24
awx/main/tests/functional/api/test_notifications.py
Normal file
@ -0,0 +1,24 @@
|
||||
import pytest
|
||||
|
||||
from awx.api.versioning import reverse
|
||||
|
||||
|
||||
@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})
|
||||
response = get(url, admin)
|
||||
assert response.status_code == 200
|
||||
assert len(response.data['results']) == 0
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_post_jt_running_notification(get, post, admin, notification_template, job_template):
|
||||
url = reverse('api:job_template_notification_templates_started_list', kwargs={'pk': 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
|
||||
@ -22,9 +22,11 @@ Notification templates assigned at certain levels will inherit notifications def
|
||||
|
||||
## Workflow
|
||||
|
||||
When a job succeeds or fails, the error or success handler will pull a list of relevant notifications using the procedure defined above. It will then create a Notification object for each one containing relevant details about the job and then **sends** it to the destination (email addresses, slack channel(s), SMS numbers, etc.). These Notification objects are available as related resources on job types (Jobs, Inventory Updates, Project Updates), and also at `/api/v2/notifications`. You may also see what notifications have been sent from a notifications by examining its related resources.
|
||||
When a job starts, succeeds or fails, the running, error or success handler will pull a list of relevant notifications using the procedure defined above. It will then create a Notification object for each one containing relevant details about the job and then **sends** it to the destination (email addresses, slack channel(s), SMS numbers, etc.). These Notification objects are available as related resources on job types (Jobs, Inventory Updates, Project Updates), and also at `/api/v2/notifications`. You may also see what notifications have been sent from a notifications by examining its related resources.
|
||||
|
||||
Notifications can succeed or fail but that will not cause its associated job to succeed or fail. The status of the notification can be viewed at its detail endpoint: `/api/v2/notifications/<n>`
|
||||
When a notification is associated to a job via the `/api/v2/.../notification_templates_any/` endpoint, it will send upon success OR fail, but _not_ on start.
|
||||
|
||||
Notifications can succeed or fail but that will _not_ cause its associated job to succeed or fail. The status of the notification can be viewed at its detail endpoint: `/api/v2/notifications/<n>`
|
||||
|
||||
## Testing Notifications Before Using Them
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user