Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrDlouhy committed Feb 3, 2020
1 parent ed19ed2 commit 0f5b625
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions admin_tools_stats/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,26 @@ def setUp(self):
graph_key="user_graph",
)

def test_clean_error_model_app_app_name(self):
stats = mommy.make('DashboardStats', model_name="User1", model_app_name="auth1", graph_key="error_graph")
with self.assertRaisesRegexp(ValidationError, "model_name.*No installed app with label"):
stats.clean()

def test_clean_error_model_name(self):
stats = mommy.make('DashboardStats', model_name="User1", model_app_name="auth", graph_key="error_graph")
with self.assertRaisesRegexp(ValidationError, "model_name.*App 'auth' doesn't have a 'User1' model."):
stats.clean()

def test_clean_error_operation_field(self):
stats = mommy.make('DashboardStats', model_name="User", model_app_name="auth", graph_key="error_graph", operation_field_name='asdf')
with self.assertRaisesRegexp(ValidationError, "operation_field_name.*Cannot resolve keyword 'asdf' into field. Choices are:"):
stats.clean()

def test_clean_error_date_field(self):
stats = mommy.make('DashboardStats', model_name="User", model_app_name="auth", graph_key="error_graph", date_field_name='asdf')
with self.assertRaisesRegexp(ValidationError, "date_field_name.*Cannot resolve keyword 'asdf' into field. Choices are:"):
stats.clean()

@override_settings(USE_TZ=False)
def test_get_multi_series(self):
"""Test function to check DashboardStats.get_multi_time_series()"""
Expand Down

0 comments on commit 0f5b625

Please sign in to comment.