Skip to content
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

Merged
merged 17 commits into from
Nov 11, 2021

Conversation

LeonRomo
Copy link
Contributor

@LeonRomo LeonRomo commented Sep 16, 2021

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:

  • [ x] Included tests
  • Updated documentation

Closes #
#2089

Comment on lines 479 to 527
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)
Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor

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.

WinnyTroy and others added 3 commits November 5, 2021 11:38
…iles upon form deletion. Add documentation on clean up of filtered datasets (#2136)
…#2144)

* Add failing tests

* Include ability to generate sql statement for NULL query strings.

* Update data endpoint documentation
@LeonRomo LeonRomo force-pushed the fix-charts-groupby-multiple-fields branch from a94612f to 9ef62f7 Compare November 5, 2021 08:39
@denniswambua denniswambua merged commit f11c688 into master Nov 11, 2021
@denniswambua denniswambua deleted the fix-charts-groupby-multiple-fields branch November 11, 2021 08:58
@DavisRayM DavisRayM mentioned this pull request Nov 17, 2021
1 task
@DavisRayM DavisRayM mentioned this pull request Nov 24, 2021
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants