def test_tag(self): all_alerts = alerts_list(user=self.staff) self.assertEqual(20, all_alerts['nb_alerts']) self.assertEqual(10, len(all_alerts['alerts'])) self.assertEqual(self.alerts[-1].text, all_alerts['alerts'][0]['text']) self.alerts[5].delete() all_alerts = alerts_list(user=self.staff) self.assertEqual(19, all_alerts['nb_alerts']) self.assertEqual(10, len(all_alerts['alerts']))
def test_no_alert_on_unpublish(self): """related to #4860""" published = PublishedContentFactory(type='OPINION', author_list=[self.user_author]) reaction = ContentReactionFactory(related_content=published, author=ProfileFactory().user, position=1, pubdate=datetime.datetime.now()) Alert.objects.create(scope='CONTENT', comment=reaction, text='a text', author=ProfileFactory().user, pubdate=datetime.datetime.now(), content=published) staff = StaffProfileFactory().user self.assertEqual(1, alerts_list(staff)['nb_alerts']) unpublish_content(published, staff) self.assertEqual(0, alerts_list(staff)['nb_alerts'])
def test_intervention_filter_for_tribunes(self): author = ProfileFactory() opinion = PublishedContentFactory(type='OPINION', author_list=[author.user]) alerter = ProfileFactory() staff = StaffProfileFactory() alert = Alert() alert.scope = 'CONTENT' alert.author = alerter.user alert.content = opinion alert.pubdate = datetime.datetime.now() alert.text = 'Something to say.' alert.save() filter_result = alerts_list(staff.user) self.assertEqual(1, filter_result['nb_alerts']) self.assertEqual(alert.text, filter_result['alerts'][0]['text'])