Example #1
0
 def test_deserialization_valid(self):
     serializer = DisaggregationSerializer(data=self.data)
     self.assertTrue(serializer.is_valid(), serializer.errors)
     disaggregation = serializer.save()
     self.assertEqual(disaggregation.name, self.data['name'])
     self.assertEqual(disaggregation.active, False)
     self.assertEqual(disaggregation.disaggregation_values.count(),
                      len(self.data['disaggregation_values']))
Example #2
0
 def test_deserialization_needs_values(self):
     del self.data['disaggregation_values']
     serializer = DisaggregationSerializer(data=self.data)
     self.assertFalse(serializer.is_valid())
     self.assertEqual(serializer.errors['disaggregation_values'], ['This field is required.'])