Skip to content

Commit

Permalink
test divide criteria generation
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrDlouhy committed Feb 20, 2020
1 parent 6d9dd3e commit 8b60441
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions admin_tools_stats/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,39 @@ def test_admin_dashboard_page(self):
html=True,
)

def test_admin_dashboard_page_multi_series(self):
stats = mommy.make(
'DashboardStats',
date_field_name="date_joined",
model_name="User",
model_app_name="auth",
graph_key="user_graph1",
)
criteria = mommy.make(
'DashboardStatsCriteria',
criteria_name="active",
dynamic_criteria_field_name="is_active",
criteria_dynamic_mapping={
"": [None, "All"],
"false": [False, "Inactive"],
"true": [True, "Active"],
},
)
mommy.make('CriteriaToStatsM2M', criteria=criteria, stats=stats, use_as='multiple_series')
response = self.client.get('/admin/')
with open("./response.html", "w") as f:
f.write(response.content.decode())
self.assertContains(
response,
'<option class="chart-input" value="">-------</option>',
html=True,
)
self.assertContains(
response,
'<option class="chart-input" value="%s" selected="selected">active</option>' % stats.id,
html=True,
)

def test_admin_dashboard_page_post(self):
"""Test function to check dashboardstatscriteria admin pages"""
response = self.client.post('/admin/', {'select_box_user_graph': 'true'})
Expand Down

0 comments on commit 8b60441

Please sign in to comment.