8356 fix tests

This commit is contained in:
Arthur 2023-11-09 17:30:40 -08:00
parent 7fae20ca51
commit 5686b96499
2 changed files with 12 additions and 19 deletions

View File

@ -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.
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(
verbose_name=_('name'),

View File

@ -335,33 +335,26 @@ class WebhookTestCase(ViewTestCases.PrimaryObjectViewTestCase):
@classmethod
def setUpTestData(cls):
site_ct = ContentType.objects.get_for_model(Site)
webhooks = (
Webhook(name='Webhook 1', payload_url='http://example.com/?1', type_create=True, http_method='POST'),
Webhook(name='Webhook 2', payload_url='http://example.com/?2', type_create=True, http_method='POST'),
Webhook(name='Webhook 3', payload_url='http://example.com/?3', 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', http_method='POST'),
Webhook(name='Webhook 3', payload_url='http://example.com/?3', http_method='POST'),
)
for webhook in webhooks:
webhook.save()
webhook.content_types.add(site_ct)
cls.form_data = {
'name': 'Webhook X',
'content_types': [site_ct.pk],
'type_create': False,
'type_update': True,
'type_delete': True,
'payload_url': 'http://example.com/?x',
'http_method': 'GET',
'http_content_type': 'application/foo',
'conditions': None,
}
cls.csv_data = (
"name,content_types,type_create,payload_url,http_method,http_content_type",
"Webhook 4,dcim.site,True,http://example.com/?4,GET,application/json",
"Webhook 5,dcim.site,True,http://example.com/?5,GET,application/json",
"Webhook 6,dcim.site,True,http://example.com/?6,GET,application/json",
"name,payload_url,http_method,http_content_type",
"Webhook 4,http://example.com/?4,GET,application/json",
"Webhook 5,http://example.com/?5,GET,application/json",
"Webhook 6,http://example.com/?6,GET,application/json",
)
cls.csv_update_data = (
@ -372,10 +365,6 @@ class WebhookTestCase(ViewTestCases.PrimaryObjectViewTestCase):
)
cls.bulk_edit_data = {
'enabled': False,
'type_create': False,
'type_update': True,
'type_delete': True,
'http_method': 'GET',
}