Skip to content

Commit

Permalink
Merge pull request #1786 from unicef/30737-allow-null-for-quantity-in…
Browse files Browse the repository at this point in the history
…dicators

Json Validator schema fix: allow NULL value for v,d,c in indicators
  • Loading branch information
robertavram authored Jul 20, 2022
2 parents eb1dd93 + 5a5d56a commit 9542387
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions django_api/etools_prp/apps/indicator/json_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"type": "object",
"additionalProperties": False,
"properties": {
"c": {"type": "number"},
"d": {"type": "number"},
"v": {"type": "number"}
"c": {"type": ["number", "null"]},
"d": {"type": ["number", "null"]},
"v": {"type": ["number", "null"]}
},
"required": ["d", "v"]
}
Expand Down
12 changes: 12 additions & 0 deletions django_api/etools_prp/apps/indicator/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2500,3 +2500,15 @@ def test_valid_serializer_values(self):
response = self.client.post(url, data=data, format='json')
self.assertTrue(status.is_success(response.status_code))
self.assertTrue(Reportable.objects.filter(id=response.data['id']).exists())

# Allow NULL for Target values
data['target'] = {'d': None, 'v': None, 'c': None}
response = self.client.post(url, data=data, format='json')
self.assertTrue(status.is_success(response.status_code))
self.assertTrue(Reportable.objects.filter(id=response.data['id']).exists())

# Allow NULL for Baseline values
data['baseline'] = {'d': None, 'v': None, 'c': None}
response = self.client.post(url, data=data, format='json')
self.assertTrue(status.is_success(response.status_code))
self.assertTrue(Reportable.objects.filter(id=response.data['id']).exists())

0 comments on commit 9542387

Please sign in to comment.