Пример #1
0
 def test_single_resource_with_bad_included(self):
     resource_object1 = {
         'id': 1,
         'type': "model_name",
         'attributes': {},
         'relationships': {},
     }
     document = {'data': resource_object1, 'included': {'nope': []}}
     valid = jsalve_utils.is_valid_top_level(document)
     self.assertFalse(valid)
Пример #2
0
 def test_single_resource(self):
     resource_object1 = {
         'id': 1,
         'type': "model_name",
         'attributes': {},
         'relationships': {},
     }
     document = {'data': resource_object1}
     valid = jsalve_utils.is_valid_top_level(document)
     self.assertTrue(valid)
Пример #3
0
 def test_collection_with_included(self):
     resource_object1 = {
         'id': 1,
         'type': "model_name",
         'attributes': {},
         'relationships': {},
     }
     resource_object2 = {
         'id': 2,
         'type': "model_name",
         'attributes': {},
         'relationships': {},
     }
     collection = [resource_object1, resource_object2]
     document = {'data': collection, 'included': []}
     valid = jsalve_utils.is_valid_top_level(document, collection=True)
     self.assertTrue(valid)
Пример #4
0
 def test_bad_meta(self):
     document = {'meta': 'content'}
     valid = jsalve_utils.is_valid_top_level(document)
     self.assertFalse(valid)
Пример #5
0
 def test_meta(self):
     document = {'meta': {}}
     valid = jsalve_utils.is_valid_top_level(document)
     self.assertTrue(valid)
Пример #6
0
 def test_bad_errors(self):
     document = {'errors': {}}
     valid = jsalve_utils.is_valid_top_level(document)
     self.assertFalse(valid)
Пример #7
0
 def test_errors(self):
     document = {'errors': []}
     valid = jsalve_utils.is_valid_top_level(document)
     self.assertTrue(valid)
Пример #8
0
 def test_included_without_data(self):
     bad_document = {'included': [], 'errors': []}
     valid = jsalve_utils.is_valid_top_level(bad_document)
     self.assertFalse(valid)
Пример #9
0
 def test_data_and_errors_collision(self):
     bad_document = {'data': {}, 'errors': []}
     valid = jsalve_utils.is_valid_top_level(bad_document)
     self.assertFalse(valid)
Пример #10
0
 def test_none_document(self):
     bad_document = None
     valid = jsalve_utils.is_valid_top_level(bad_document)
     self.assertFalse(valid)
Пример #11
0
 def test_bad_document(self):
     bad_document = {'bad_member': []}
     valid = jsalve_utils.is_valid_top_level(bad_document)
     self.assertFalse(valid)