Clean up API tests

This commit is contained in:
Jeremy Stretch 2023-11-29 10:01:35 -05:00
parent bce43eabc9
commit 2252c8ba01
2 changed files with 14 additions and 9 deletions

View File

@ -78,7 +78,7 @@ class EventRuleSerializer(NetBoxModelSerializer):
fields = [
'id', 'url', 'display', 'content_types', 'name', 'type_create', 'type_update', 'type_delete',
'type_job_start', 'type_job_end', 'enabled', 'conditions', 'action_type', 'action_object_type',
'action_object_id', 'action_object', 'custom_fields', 'tags', 'created', 'last_updated',
'action_object_id', 'action_object', 'description', 'custom_fields', 'tags', 'created', 'last_updated',
]
@extend_schema_field(OpenApiTypes.OBJECT)

View File

@ -72,6 +72,15 @@ class WebhookTest(APIViewTestCases.APIViewTestCase):
class EventRuleTest(APIViewTestCases.APIViewTestCase):
model = EventRule
brief_fields = ['display', 'id', 'name',]
bulk_update_data = {
'enabled': False,
'description': 'New description',
}
update_data = {
'name': 'Event Rule X',
'enabled': False,
'description': 'New description',
}
@classmethod
def setUpTestData(cls):
@ -103,18 +112,14 @@ class EventRuleTest(APIViewTestCases.APIViewTestCase):
)
Webhook.objects.bulk_create(webhooks)
def setUp(self):
super().setUp()
webhooks = Webhook.objects.all()
event_rules = (
EventRule(name='EventRule 1', action_object=webhooks[0]),
EventRule(name='EventRule 2', action_object=webhooks[1]),
EventRule(name='EventRule 3', action_object=webhooks[2]),
EventRule(name='EventRule 1', type_create=True, action_object=webhooks[0]),
EventRule(name='EventRule 2', type_create=True, action_object=webhooks[1]),
EventRule(name='EventRule 3', type_create=True, action_object=webhooks[2]),
)
EventRule.objects.bulk_create(event_rules)
self.create_data = [
cls.create_data = [
{
'name': 'EventRule 4',
'content_types': ['dcim.device', 'dcim.devicetype'],