def test_should_post_a_single_disaster(self): disaster = Disaster(**self.disaster_to_post).save() self.disaster_to_post['description'] = "Giant Flood" response = self.client.post(self.API_ENDPOINT + str(disaster.id) + '/', data=json.dumps(self.disaster_to_post), content_type="application/json") self.assertEqual(200, response.status_code) retrieved_disaster = Disaster.objects(description="Giant Flood") self.assertEqual(1, retrieved_disaster.count())
def query_by_disaster_type(self, disaster_type, queryset=None): disaster_type = DisasterType.objects(id=disaster_type).first() disasters = Disaster.objects(name=disaster_type) return queryset.filter(disaster__in=disasters)
def test_should_post_a_disaster(self): response = self.client.post(self.API_ENDPOINT, data=json.dumps(self.disaster_to_post), content_type="application/json") self.assertEqual(201, response.status_code) retrieved_disaster = Disaster.objects(description="Big Flood") self.assertEqual(1, retrieved_disaster.count())