def test_check_required_fields_single_non_id_field(self): data = {"Query": "query string"} with self.assertRaisesRegex(ValidationError, "If only a single field is specified " "it should be a unique identifier like " "'Id' or 'Name'."): PushTopicSchema().load(data)
def test_check_api_version(self): data = { "Name": "name", "ApiVersion": 22, "Query": "query string", "NotifyForOperations": "All" } PushTopicSchema().load(data)
def test_check_required_fields_no_fields(self): data = {} with self.assertRaisesRegex(ValidationError, "'Either a single fields should be " "specified which uniquely identifies the " "resource or multiple fields which can be " "used to construct the resource.'"): PushTopicSchema().load(data)
def test_check_api_version_invalid_version(self): data = { "Name": "name", "ApiVersion": 12, "Query": "query string", "NotifyForOperations": "All" } with self.assertRaisesRegex(ValidationError, "'ApiVersion'"): PushTopicSchema().load(data)
def test_check_required_fields_multiple_definition_fields(self): data = { "Name": "name", "ApiVersion": 28, "Query": "query string" } result = PushTopicSchema().load(data) self.assertEqual(result, data)
def test_check_api_version_invalid_notify_for_undelete(self): data = { "Name": "name", "ApiVersion": 28, "Query": "query string", "NotifyForOperationUndelete": True } with self.assertRaisesRegex(ValidationError, self.invalid_operation_for_erlier_error): PushTopicSchema().load(data)
def test_check_required_fields_multiple_definition_fields_missing(self): data = { "Name": "name", "Query": "query string" } with self.assertRaisesRegex(ValidationError, "If multiple fields are specified it " "it should be a full resource " "definition where at least 'Name', " "'ApiVersion' and 'Query' are required."): PushTopicSchema().load(data)
def test_check_api_version_invalid_notify_for_operations(self): data = { "Name": "name", "ApiVersion": 29, "Query": "query string", "NotifyForOperations": "All" } with self.assertRaisesRegex(ValidationError, "'NotifyForOperations' can only be " "specified for API version 28.0 and " "earlier."): PushTopicSchema().load(data)
def test_check_required_fields_single_name_field(self): data = {"Name": "name"} result = PushTopicSchema().load(data) self.assertEqual(result, data)