Exemple #1
0
    def test_editing_existing_message_is_valid(self):
        district = Location(
            **dict(name='Kampala', type='district', parent=None)).save()
        disaster_type = DisasterType(
            **dict(name="Fire", description="Fire")).save()

        disaster_attributes = dict(name=disaster_type,
                                   locations=[district],
                                   description="Big Flood",
                                   date="2014-12-01 00:00:00",
                                   status="Assessment")
        disaster = Disaster(**disaster_attributes).save()

        message = RapidProMessage(**self.serialized_data).save()

        data = self.serialized_data.copy()
        data['disaster'] = disaster.id

        serializer = RapidProMessageSerializer(message, data=data)

        self.assertTrue(serializer.is_valid())
        new_message = serializer.save()

        self.assertTrue(message.id, new_message.id)
        self.assertEqual(disaster, new_message.disaster)
Exemple #2
0
    def test_should_deserialize_rapid_pro_message_object(self):
        serializer = RapidProMessageSerializer(data=self.serialized_data)

        self.assertTrue(serializer.is_valid())

        saved_message = serializer.save()

        self.assertTrue(isinstance(saved_message, RapidProMessage))
        for attribute, value in self.message.items():
            self.assertEqual(value, getattr(saved_message, attribute))