def test_get_time_seen(self):
     self.client.force_authenticate(user=self.user)
     notification = Notification(
         action_name="This is it! a notification").save()
     notification.notification_from.connect(self.pleb)
     notification.notification_to.connect(self.pleb)
     url = "%s?seen=true" % reverse('notification-list')
     self.client.get(url, format='json')
     url = reverse('notification-detail',
                   kwargs={'object_uuid': notification.object_uuid})
     response = self.client.get(url, format='json')
     notification.refresh()
     self.assertEqual(parser.parse(response.data['time_seen']).isoformat(),
                      notification.time_seen.isoformat())
 def test_get_system_notification(self):
     self.client.force_authenticate(user=self.user)
     notification = Notification(
         action_name="This is it! a notification").save()
     notification.notification_to.connect(self.pleb)
     url = reverse('notification-detail',
                   kwargs={'object_uuid': notification.object_uuid})
     response = self.client.get(url, format='json')
     self.assertFalse(response.data['notification_from'])
 def test_list_unseen(self):
     self.client.force_authenticate(user=self.user)
     notification = Notification(
         action_name="This is it! a notification").save()
     notification.notification_from.connect(self.pleb)
     notification.notification_to.connect(self.pleb)
     url = reverse('notification-unseen')
     response = self.client.get(url, format='json')
     self.assertGreater(response.data['unseen'], 0)
 def test_list_seen_api(self):
     self.client.force_authenticate(user=self.user)
     notification = Notification(
         action_name="This is it! a notification").save()
     notification.notification_from.connect(self.pleb)
     notification.notification_to.connect(self.pleb)
     url = "%s?seen=true" % reverse('notification-list')
     response = self.client.get(url, format='json')
     self.assertEqual(response.data['results'], [])
Esempio n. 5
0
    def test_create_post_notification_already_exists_not_sent(self):
        notification = Notification().save()
        post = Post(object_uuid=uuid1(), content='as;ldkfja;')
        post.save()
        response = create_notification_util(post.object_uuid, self.pleb,
                                            [self.pleb2],
                                            notification.object_uuid, self.url,
                                            post.action_name)

        self.assertTrue(response)
Esempio n. 6
0
 def test_create_system_notification_exists(self):
     notification = Notification().save()
     res = create_system_notification(
         [self.pleb], notification.object_uuid,
         reverse('profile_page',
                 kwargs={"pleb_username": self.pleb.username}),
         "This is a test notification!")
     self.assertTrue(res)
     notification = Notification.nodes.get(
         object_uuid=notification.object_uuid)
     self.assertTrue(self.pleb in notification.notification_to)
Esempio n. 7
0
 def test_create_comment_notification_already_exists_not_sent(self):
     comment = Comment(content='sdfasd')
     comment.save()
     notification = Notification().save()
     post = Post(content='as;ldkfja;')
     post.save()
     response = create_notification_util(comment.object_uuid, self.pleb,
                                         [self.pleb2],
                                         notification.object_uuid, self.url,
                                         post.action_name)
     self.assertTrue(response)
 def test_cannot_destroy(self):
     self.client.force_authenticate(user=self.user)
     cache.clear()
     notification = Notification(
         action_name="This is it! a notification").save()
     notification.notification_from.connect(self.pleb)
     notification.notification_to.connect(self.pleb)
     url = reverse('notification-detail',
                   kwargs={'object_uuid': notification.object_uuid})
     response = self.client.delete(url, format='json')
     self.assertEqual(response.status_code,
                      status.HTTP_405_METHOD_NOT_ALLOWED)