Example #1
0
    def test_get_for_group_id(self):
        """If no groups are passed, nothing is returned."""
        # Site-wide announcement
        AnnouncementFactory()
        # Announcement in a group.
        a = AnnouncementFactory(group=self.group)

        group_ann = Announcement.get_for_group_id(self.group.id)
        eq_(1, len(group_ann))
        eq_(a, group_ann[0])
Example #2
0
    def test_get_for_locale_name(self):
        """Announcements for a specific locale are shown."""
        # Site-wide announcement
        AnnouncementFactory()
        # Announcement in a locale
        a = AnnouncementFactory(locale=self.locale)

        locale_ann = Announcement.get_for_locale_name(self.locale.locale)
        eq_(1, locale_ann.count())
        eq_(a, locale_ann[0])
Example #3
0
    def test_always_visible(self):
        """Always visible announcements are shown."""
        # This one doesn't show
        AnnouncementFactory(show_after=datetime.now() + timedelta(days=2))
        AnnouncementFactory(show_after=datetime.now() - timedelta(days=2),
                            content='stardate 43125')

        site_wide = Announcement.get_site_wide()
        eq_(1, site_wide.count())
        eq_('stardate 43125', site_wide[0].content)
Example #4
0
 def test_active(self):
     """Active announcement shows."""
     AnnouncementFactory(
         show_after=datetime.now() - timedelta(days=2),
         show_until=datetime.now() + timedelta(days=2),
     )
     eq_(1, Announcement.get_site_wide().count())
Example #5
0
    def _setup_announcement(self, visible_dates=True):
        g = GroupFactory()
        u1 = UserFactory(groups=[g])
        u2 = UserFactory(groups=[g])
        self.user = u2

        return AnnouncementFactory(creator=u1, group=g, visible_dates=visible_dates)
Example #6
0
    def setUp(self):
        self.locale = LocaleFactory(locale='es')

        self.u = UserFactory()

        self.locale.leaders.add(self.u)
        self.locale.save()

        self.announcement = AnnouncementFactory(creator=self.u,
                                                locale=self.locale,
                                                content="Look at me!",
                                                show_after=datetime(
                                                    2012, 1, 1, 0, 0, 0))
Example #7
0
 def test_group_excluded(self):
     """Announcements in a group are not shown."""
     AnnouncementFactory(group=self.group)
     eq_(0, Announcement.get_site_wide().count())