Populate bulk_update_invalid_data for extras API tests
Give each extras test class an invalid payload so test_bulk_update_objects_validation_error runs instead of skipping. extras serializers are more varied than dcim's, so fewer classes had a plain choice field to work with: the config context and template classes use a nonexistent data_source pk, and the saved filter, table config, export template and subscription classes use an invalid content type. Two fields were deliberately avoided. CustomField uses filter_logic rather than type, because validate_type rejects any type change on an existing instance and would fail for the wrong reason. EventRule uses action_type rather than event_types, whose ArrayField choices do not map to a reliable serializer error. All 16 extras API test classes now run the test.
This commit is contained in:
parent
17ebddd0f2
commit
de595f6a98
|
|
@ -62,6 +62,9 @@ class WebhookTestCase(APIViewTestCases.APIViewTestCase):
|
|||
'description': 'New description',
|
||||
'ssl_verification': False,
|
||||
}
|
||||
bulk_update_invalid_data = {
|
||||
'http_method': 'not-a-valid-http-method',
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
|
|
@ -90,6 +93,9 @@ class EventRuleTestCase(APIViewTestCases.APIViewTestCase):
|
|||
'enabled': False,
|
||||
'description': 'New description',
|
||||
}
|
||||
bulk_update_invalid_data = {
|
||||
'action_type': 'not-a-valid-action-type',
|
||||
}
|
||||
update_data = {
|
||||
'name': 'Event Rule X',
|
||||
'enabled': False,
|
||||
|
|
@ -308,6 +314,9 @@ class CustomFieldTestCase(APIViewTestCases.APIViewTestCase):
|
|||
'description': 'New description',
|
||||
'nulls_first': False,
|
||||
}
|
||||
bulk_update_invalid_data = {
|
||||
'filter_logic': 'not-a-valid-filter-logic',
|
||||
}
|
||||
update_data = {
|
||||
'object_types': ['dcim.device'],
|
||||
'name': 'New_Name',
|
||||
|
|
@ -377,6 +386,9 @@ class CustomFieldChoiceSetTestCase(APIViewTestCases.APIViewTestCase):
|
|||
bulk_update_data = {
|
||||
'description': 'New description',
|
||||
}
|
||||
bulk_update_invalid_data = {
|
||||
'base_choices': 'not-a-valid-base-choices',
|
||||
}
|
||||
update_data = {
|
||||
'name': 'Choice Set X',
|
||||
'extra_choices': [
|
||||
|
|
@ -577,6 +589,9 @@ class CustomLinkTestCase(APIViewTestCases.APIViewTestCase):
|
|||
'new_window': True,
|
||||
'enabled': False,
|
||||
}
|
||||
bulk_update_invalid_data = {
|
||||
'button_class': 'not-a-valid-button-class',
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
|
|
@ -661,6 +676,9 @@ class SavedFilterTestCase(SharedObjectAPITestMixin, APIViewTestCases.APIViewTest
|
|||
'enabled': False,
|
||||
'shared': False,
|
||||
}
|
||||
bulk_update_invalid_data = {
|
||||
'object_types': ['dcim.notamodel'],
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
|
|
@ -753,6 +771,9 @@ class TableConfigTestCase(SharedObjectAPITestMixin, APIViewTestCases.APIViewTest
|
|||
'enabled': False,
|
||||
'shared': False,
|
||||
}
|
||||
bulk_update_invalid_data = {
|
||||
'object_type': 'dcim.notamodel',
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
|
|
@ -942,6 +963,9 @@ class ExportTemplateTestCase(APIViewTestCases.APIViewTestCase):
|
|||
bulk_update_data = {
|
||||
'description': 'New description',
|
||||
}
|
||||
bulk_update_invalid_data = {
|
||||
'object_types': ['dcim.notamodel'],
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
|
|
@ -989,6 +1013,9 @@ class TagTestCase(APIViewTestCases.APIViewTestCase):
|
|||
bulk_update_data = {
|
||||
'description': 'New description',
|
||||
}
|
||||
bulk_update_invalid_data = {
|
||||
'color': 'not-a-color',
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
|
|
@ -1083,6 +1110,9 @@ class JournalEntryTestCase(APIViewTestCases.APIViewTestCase):
|
|||
bulk_update_data = {
|
||||
'comments': 'Overwritten',
|
||||
}
|
||||
bulk_update_invalid_data = {
|
||||
'kind': 'not-a-valid-kind',
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
|
|
@ -1169,6 +1199,9 @@ class ConfigContextProfileTestCase(APIViewTestCases.APIViewTestCase):
|
|||
bulk_update_data = {
|
||||
'description': 'New description',
|
||||
}
|
||||
bulk_update_invalid_data = {
|
||||
'data_source': 99999,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
|
|
@ -1281,6 +1314,9 @@ class ConfigContextTestCase(APIViewTestCases.APIViewTestCase):
|
|||
bulk_update_data = {
|
||||
'description': 'New description',
|
||||
}
|
||||
bulk_update_invalid_data = {
|
||||
'data_source': 99999,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
|
|
@ -1411,6 +1447,9 @@ class ConfigTemplateTestCase(APIViewTestCases.APIViewTestCase):
|
|||
bulk_update_data = {
|
||||
'description': 'New description',
|
||||
}
|
||||
bulk_update_invalid_data = {
|
||||
'data_source': 99999,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
|
|
@ -2226,6 +2265,9 @@ class SubscriptionTestCase(APIViewTestCases.APIViewTestCase):
|
|||
cls.bulk_update_data = {
|
||||
'user': users[3].pk,
|
||||
}
|
||||
cls.bulk_update_invalid_data = {
|
||||
'object_type': 'dcim.notamodel',
|
||||
}
|
||||
|
||||
|
||||
class NotificationGroupTestCase(APIViewTestCases.APIViewTestCase):
|
||||
|
|
@ -2257,6 +2299,9 @@ class NotificationGroupTestCase(APIViewTestCases.APIViewTestCase):
|
|||
bulk_update_data = {
|
||||
'description': 'New description',
|
||||
}
|
||||
bulk_update_invalid_data = {
|
||||
'users': [99999],
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
|
|
@ -2311,6 +2356,9 @@ class NotificationTestCase(APIViewTestCases.APIViewTestCase):
|
|||
bulk_update_data = {
|
||||
'read': now(),
|
||||
}
|
||||
bulk_update_invalid_data = {
|
||||
'event_type': 'not-a-valid-event-type',
|
||||
}
|
||||
graphql_filter = {
|
||||
'event_type': {'lookup': 'exact', 'value': OBJECT_CREATED},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue