-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix charts groupby multiple fields and check content type #2151
Conversation
Co-authored-by: Davis Raymond <[email protected]>
def test_charts_groupby_two_fields(self): | ||
data = { | ||
'field_name': 'age', | ||
'group_by': 'gender,pizza_fan' | ||
} | ||
request = self.factory.get('/charts', data) | ||
force_authenticate(request, user=self.user) | ||
response = self.view( | ||
request, | ||
pk=self.xform.id, | ||
format='json') | ||
|
||
expected = { | ||
'data': [ | ||
{ | ||
'gender': ['Female'], | ||
'pizza_fan': ['No'], | ||
'count': 1, | ||
'sum': 23.0, | ||
'mean': 23.0 | ||
}, | ||
{ | ||
'gender': ['Female'], | ||
'pizza_fan': ['Yes'], | ||
'count': 1, | ||
'sum': 23.0, | ||
'mean': 23.0 | ||
}, | ||
{ | ||
'gender': ['Male'], | ||
'pizza_fan': ['No'], | ||
'count': 1, | ||
'sum': 35.0, | ||
'mean': 35.0 | ||
} | ||
], | ||
'data_type': 'numeric', | ||
'field_label': 'How old are you?', | ||
'field_xpath': 'age', | ||
'field_name': 'age', | ||
'field_type': 'integer', | ||
'grouped_by': ['gender', 'pizza_fan'], | ||
'xform': self.xform.pk | ||
} | ||
|
||
response.render() | ||
res = json.loads(response.content.decode('utf-8')) | ||
self.assertEqual(200, response.status_code) | ||
self.assertEqual(expected, res) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LeonRomo In what scenario would this test fail? Doesn't seem to fail on the current master branch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DavisRayM I don't think that funtionality has been tested and this is good to test it and increase our test coverage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@denniswambua Thought it was related to one of the issues this closes #2090. If it's not then we may need to add a test for it since I don't see a test for it in this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DavisRayM it is testing #2090
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@denniswambua I would then expect the test to fail on master.... unless the issue is no longer occurring in the latest release.
a94612f
to
9ef62f7
Compare
Co-authored-by: Davis Raymond <[email protected]>
Changes / Features implemented
test on charts by grouping multiple fields.
test on charts with content-type as application/JSON
update the format to JSON in the even content type has been provided
Steps taken to verify this change does what is intended
tested locally and used the unit test
Side effects of implementing this change
N/A
Before submitting this PR for review, please make sure you have:
Closes #
#2089