示例#1
0
 def test_single_resource_object(self):
     resource_object = {
         'id': 1,
         'type': "model_name",
         'attributes': {},
         'relationships': {},
     }
     valid = jsalve_utils.is_valid_primary_data(resource_object)
     self.assertTrue(valid)
示例#2
0
 def test_bad_mixed_resource_collection(self):
     resource_object = {
         'id': 1,
         'type': "model_name",
         'attributes': {},
         'relationships': {},
     }
     bad_collection = [
         resource_object,
         {'nope': []},
     ]
     valid = jsalve_utils.is_valid_primary_data(bad_collection, True)
     self.assertFalse(valid)
示例#3
0
 def test_resource_collection(self):
     resource_object1 = {
         'id': 1,
         'type': "model_name",
         'attributes': {},
         'relationships': {},
     }
     resource_object2 = {
         'id': 2,
         'type': "model_name",
         'attributes': {},
         'relationships': {},
     }
     collection = [resource_object1, resource_object2]
     valid = jsalve_utils.is_valid_primary_data(collection, True)
     self.assertTrue(valid)
示例#4
0
 def test_null_collection(self):
     valid = jsalve_utils.is_valid_primary_data(None, True)
     self.assertFalse(valid)
示例#5
0
 def test_empty_collection(self):
     valid = jsalve_utils.is_valid_primary_data([], True)
     self.assertTrue(valid)
示例#6
0
 def test_bad_resource_collection(self):
     bad_collection = [{'nope': []}, {'bad': []}]
     valid = jsalve_utils.is_valid_primary_data(bad_collection, True)
     self.assertFalse(valid)
示例#7
0
 def test_single_resource_identifier(self):
     resource_identifier = {'id': 1, 'type': "model_name"}
     valid = jsalve_utils.is_valid_primary_data(resource_identifier)
     self.assertTrue(valid)
示例#8
0
 def test_null_single_resource(self):
     valid = jsalve_utils.is_valid_primary_data(None)
     self.assertTrue(valid)
示例#9
0
 def test_bad_single_resource(self):
     bad_data = {'nope': []}
     valid = jsalve_utils.is_valid_primary_data(bad_data)
     self.assertFalse(valid)