correct test for items

This commit is contained in:
Samuel Spencer 2015-07-21 00:10:25 +00:00
parent 3b4b728b8f
commit 65c74a836b

View file

@ -240,34 +240,34 @@ class NotificationTestPages(TestCase):
response = self.client.get(reverse('notifications:live_unread_notification_list'))
data = json.loads(response.content.decode('utf-8'))
self.assertListEqual(list(data.keys()),['unread_count','unread_list'])
self.assertItemsEqual(list(data.keys()),['unread_count','unread_list'])
self.assertEqual(data['unread_count'],10)
self.assertEqual(len(data['unread_list']),5)
response = self.client.get(reverse('notifications:live_unread_notification_list')+"?max=12")
data = json.loads(response.content.decode('utf-8'))
self.assertListEqual(list(data.keys()),['unread_count','unread_list'])
self.assertItemsEqual(list(data.keys()),['unread_count','unread_list'])
self.assertEqual(data['unread_count'],10)
self.assertEqual(len(data['unread_list']),10)
# Test with a bad 'max' value
response = self.client.get(reverse('notifications:live_unread_notification_list')+"?max=this_is_wrong")
data = json.loads(response.content.decode('utf-8'))
self.assertListEqual(list(data.keys()),['unread_count','unread_list'])
self.assertItemsEqual(list(data.keys()),['unread_count','unread_list'])
self.assertEqual(data['unread_count'],10)
self.assertEqual(len(data['unread_list']),5)
Notification.objects.filter(recipient=self.to_user).mark_all_as_read()
response = self.client.get(reverse('notifications:live_unread_notification_list'))
data = json.loads(response.content.decode('utf-8'))
self.assertListEqual(list(data.keys()),['unread_count','unread_list'])
self.assertItemsEqual(list(data.keys()),['unread_count','unread_list'])
self.assertEqual(data['unread_count'],0)
self.assertEqual(len(data['unread_list']),0)
notify.send(self.from_user, recipient=self.to_user, verb='commented', action_object=self.from_user)
response = self.client.get(reverse('notifications:live_unread_notification_list'))
data = json.loads(response.content.decode('utf-8'))
self.assertListEqual(list(data.keys())),['unread_count','unread_list'])
self.assertItemsEqual(list(data.keys()),['unread_count','unread_list'])
self.assertEqual(data['unread_count'],1)
self.assertEqual(len(data['unread_list']),1)
self.assertEqual(data['unread_list'][0]['verb'],'commented')