From f688228e756d8e25c53995aa37204cd2307c0079 Mon Sep 17 00:00:00 2001 From: Felipe Bormann Date: Thu, 4 May 2017 12:04:32 -0300 Subject: [PATCH] test for JSON in most used tags is now passing OK and behaving as expected --- analytics/tests/test_api.py | 16 +++++++++++++--- analytics/views.py | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/analytics/tests/test_api.py b/analytics/tests/test_api.py index 3e82598..a4976a9 100644 --- a/analytics/tests/test_api.py +++ b/analytics/tests/test_api.py @@ -21,6 +21,10 @@ class APIDashBoardTest(TestCase): def test_most_used_tags(self): + + """ + testing if the catches all tags used in a resource and in a subject + """ t = Tag(name="felipe") t.save() t1 = Tag(name="b2") @@ -39,7 +43,13 @@ class APIDashBoardTest(TestCase): r1.save() - expected_data = {'felipe': 2, 'b2': 1} + expected_data = [{'name': 'felipe', 'count': 2}, {'name':'b2', 'count': 1}] data = self.c.get('/analytics/most_used_tags/') - print(data) - self.assertEqual(data, expected_data) + self.assertEqual(data.status_code, 200 ) + self.assertJSONEqual(str(data.content, encoding='UTF-8'), expected_data) + + def test_most_accessed_subjects(self): + return None + + def test_most_active_users(self): + return None diff --git a/analytics/views.py b/analytics/views.py index 546093f..a268fb9 100644 --- a/analytics/views.py +++ b/analytics/views.py @@ -82,7 +82,7 @@ def most_accessed_resource_kind(request): return None -def get_users_log(request): +def most_active_users(request): fifty_users = Log.objects.values('user_id').annotate(count = Count('user_id')).order_by('-count')[:50] fifty_users = list(fifty_users) for user in fifty_users: -- libgit2 0.21.2