Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions deployments/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

OperationTypes,
ProgrammeTypes,
Statuses,
)
from api.serializers import (
DisasterTypeSerializer,
Expand Down Expand Up @@ -131,9 +130,7 @@ def validate(self, data):
for project in data['project_districts'][1:]:
if project.country != data['project_country']:
raise serializers.ValidationError(ugettext('Different country found for given districts'))
if data['status'] == Statuses.COMPLETED and data.get('reached_total') is None:
raise serializers.ValidationError(ugettext('Reached total should be provided if status is completed'))
elif (
if (
data['operation_type'] == OperationTypes.EMERGENCY_OPERATION and
data['programme_type'] == ProgrammeTypes.MULTILATERAL and
data.get('event') is None
Expand Down
13 changes: 1 addition & 12 deletions deployments/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,9 @@ def test_2(self):
self.assertEqual(resp.status_code, 201, resp.content)

# Validation Tests
# Reached total should be provided if status is completed
body['status'] = Statuses.COMPLETED.value
body['reached_total'] = '' # The new framework does not allow None to be sent.
resp = self.client.post('/api/v2/project/', body)
self.assertEqual(resp.status_code, 400, resp.content)

# Disaster Type should be provided if operation type is Long Term Operation
body['operation_type'] = OperationTypes.PROGRAMME.value
body['dtype'] = ''
resp = self.client.post('/api/v2/project/', body)
self.assertEqual(resp.status_code, 400, resp.content)

# Event should be provided if operation type is Emergency Operation and programme type is Multilateral
body['operation_type'] = OperationTypes.PROGRAMME.value
body['operation_type'] = OperationTypes.EMERGENCY_OPERATION.value
body['programme_type'] = ProgrammeTypes.MULTILATERAL.value
body['event'] = ''
resp = self.client.post('/api/v2/project/', body)
Expand Down