mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-23 16:06:43 -06:00
8356 fix tests
This commit is contained in:
parent
7fae20ca51
commit
5686b96499
@ -165,7 +165,11 @@ class Webhook(CustomFieldsMixin, ExportTemplatesMixin, TagsMixin, ChangeLoggedMo
|
|||||||
delete in NetBox. The request will contain a representation of the object, which the remote application can act on.
|
delete in NetBox. The request will contain a representation of the object, which the remote application can act on.
|
||||||
Each Webhook can be limited to firing only on certain actions or certain object types.
|
Each Webhook can be limited to firing only on certain actions or certain object types.
|
||||||
"""
|
"""
|
||||||
events = GenericRelation(EventRule)
|
events = GenericRelation(
|
||||||
|
EventRule,
|
||||||
|
content_type_field='action_object_type',
|
||||||
|
object_id_field='action_object_id'
|
||||||
|
)
|
||||||
|
|
||||||
name = models.CharField(
|
name = models.CharField(
|
||||||
verbose_name=_('name'),
|
verbose_name=_('name'),
|
||||||
|
@ -335,33 +335,26 @@ class WebhookTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
|
|
||||||
site_ct = ContentType.objects.get_for_model(Site)
|
|
||||||
webhooks = (
|
webhooks = (
|
||||||
Webhook(name='Webhook 1', payload_url='http://example.com/?1', type_create=True, http_method='POST'),
|
Webhook(name='Webhook 1', payload_url='http://example.com/?1', http_method='POST'),
|
||||||
Webhook(name='Webhook 2', payload_url='http://example.com/?2', type_create=True, http_method='POST'),
|
Webhook(name='Webhook 2', payload_url='http://example.com/?2', http_method='POST'),
|
||||||
Webhook(name='Webhook 3', payload_url='http://example.com/?3', type_create=True, http_method='POST'),
|
Webhook(name='Webhook 3', payload_url='http://example.com/?3', http_method='POST'),
|
||||||
)
|
)
|
||||||
for webhook in webhooks:
|
for webhook in webhooks:
|
||||||
webhook.save()
|
webhook.save()
|
||||||
webhook.content_types.add(site_ct)
|
|
||||||
|
|
||||||
cls.form_data = {
|
cls.form_data = {
|
||||||
'name': 'Webhook X',
|
'name': 'Webhook X',
|
||||||
'content_types': [site_ct.pk],
|
|
||||||
'type_create': False,
|
|
||||||
'type_update': True,
|
|
||||||
'type_delete': True,
|
|
||||||
'payload_url': 'http://example.com/?x',
|
'payload_url': 'http://example.com/?x',
|
||||||
'http_method': 'GET',
|
'http_method': 'GET',
|
||||||
'http_content_type': 'application/foo',
|
'http_content_type': 'application/foo',
|
||||||
'conditions': None,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.csv_data = (
|
cls.csv_data = (
|
||||||
"name,content_types,type_create,payload_url,http_method,http_content_type",
|
"name,payload_url,http_method,http_content_type",
|
||||||
"Webhook 4,dcim.site,True,http://example.com/?4,GET,application/json",
|
"Webhook 4,http://example.com/?4,GET,application/json",
|
||||||
"Webhook 5,dcim.site,True,http://example.com/?5,GET,application/json",
|
"Webhook 5,http://example.com/?5,GET,application/json",
|
||||||
"Webhook 6,dcim.site,True,http://example.com/?6,GET,application/json",
|
"Webhook 6,http://example.com/?6,GET,application/json",
|
||||||
)
|
)
|
||||||
|
|
||||||
cls.csv_update_data = (
|
cls.csv_update_data = (
|
||||||
@ -372,10 +365,6 @@ class WebhookTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
cls.bulk_edit_data = {
|
cls.bulk_edit_data = {
|
||||||
'enabled': False,
|
|
||||||
'type_create': False,
|
|
||||||
'type_update': True,
|
|
||||||
'type_delete': True,
|
|
||||||
'http_method': 'GET',
|
'http_method': 'GET',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user