Commit f688228e756d8e25c53995aa37204cd2307c0079

Authored by Felipe Bormann
1 parent b0a26a3b

test for JSON in most used tags is now passing OK and behaving as expected

Showing 2 changed files with 14 additions and 4 deletions   Show diff stats
analytics/tests/test_api.py
... ... @@ -21,6 +21,10 @@ class APIDashBoardTest(TestCase):
21 21  
22 22  
23 23 def test_most_used_tags(self):
  24 +
  25 + """
  26 + testing if the catches all tags used in a resource and in a subject
  27 + """
24 28 t = Tag(name="felipe")
25 29 t.save()
26 30 t1 = Tag(name="b2")
... ... @@ -39,7 +43,13 @@ class APIDashBoardTest(TestCase):
39 43 r1.save()
40 44  
41 45  
42   - expected_data = {'felipe': 2, 'b2': 1}
  46 + expected_data = [{'name': 'felipe', 'count': 2}, {'name':'b2', 'count': 1}]
43 47 data = self.c.get('/analytics/most_used_tags/')
44   - print(data)
45   - self.assertEqual(data, expected_data)
  48 + self.assertEqual(data.status_code, 200 )
  49 + self.assertJSONEqual(str(data.content, encoding='UTF-8'), expected_data)
  50 +
  51 + def test_most_accessed_subjects(self):
  52 + return None
  53 +
  54 + def test_most_active_users(self):
  55 + return None
... ...
analytics/views.py
... ... @@ -82,7 +82,7 @@ def most_accessed_resource_kind(request):
82 82 return None
83 83  
84 84  
85   -def get_users_log(request):
  85 +def most_active_users(request):
86 86 fifty_users = Log.objects.values('user_id').annotate(count = Count('user_id')).order_by('-count')[:50]
87 87 fifty_users = list(fifty_users)
88 88 for user in fifty_users:
... ...