Пример #1
0
    def test_locale_list(self):
        """Verify the locale list renders all locales."""
        LocaleFactory(locale='en-US')
        LocaleFactory(locale='es')
        LocaleFactory(locale='de')

        r = self.client.get(reverse('wiki.locales'))
        eq_(r.status_code, 200)
        doc = pq(r.content)
        eq_(Locale.objects.count(), len(doc('#locale-listing li')))
Пример #2
0
    def test_locale_list(self):
        """Verify the locale list renders all locales."""
        LocaleFactory(locale="en-US")
        LocaleFactory(locale="es")
        LocaleFactory(locale="de")

        r = self.client.get(reverse("wiki.locales"))
        eq_(r.status_code, 200)
        doc = pq(r.content)
        eq_(Locale.objects.count(), len(doc("#locale-listing li")))
Пример #3
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))
Пример #4
0
 def setUp(self):
     super(AddRemoveReviewerTests, self).setUp()
     self.locale = LocaleFactory(locale="es")
     self.user = UserFactory()
     self.locale.leaders.add(self.user)
     self.reviewer = UserFactory()
     self.client.login(username=self.user.username, password="******")
Пример #5
0
 def setUp(self):
     super(AddRemoveLeaderTests, self).setUp()
     self.locale = LocaleFactory(locale="es")
     self.user = UserFactory()
     add_permission(self.user, Locale, "change_locale")
     self.leader = UserFactory()
     self.client.login(username=self.user.username, password="******")
Пример #6
0
 def setUp(self):
     super(AddRemoveEditorTests, self).setUp()
     self.locale = LocaleFactory(locale='es')
     self.user = UserFactory()
     self.locale.leaders.add(self.user)
     self.editor = UserFactory()
     self.client.login(username=self.user.username, password='******')
Пример #7
0
class TestDeleteAnnouncement(TestCase):
    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),
        )

    def _delete_test(self, id, status, count):
        """Login, or other setup, then call this."""
        url = reverse("announcements.delete", locale="es", args=(id, ))
        resp = self.client.post(url)
        eq_(resp.status_code, status)
        eq_(Announcement.objects.count(), count)

    def test_delete(self):
        u = UserFactory(is_superuser=1)
        self.client.login(username=u.username, password="******")
        self._delete_test(self.announcement.id, 204, 0)

    def test_leader(self):
        # Use the user that was created in setUp.
        self.client.login(username=self.u.username, password="******")
        self._delete_test(self.announcement.id, 204, 0)

    def test_has_permission(self):
        u = UserFactory()
        add_permission(u, Announcement, "add_announcement")
        self.client.login(username=u.username, password="******")
        self._delete_test(self.announcement.id, 204, 0)

    def test_no_perms(self):
        u = UserFactory()
        self.client.login(username=u.username, password="******")
        self._delete_test(self.announcement.id, 403, 1)

    def test_anon(self):
        self._delete_test(self.announcement.id, 302, 1)
Пример #8
0
class TestDeleteAnnouncement(TestCase):

    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))

    def _delete_test(self, id, status, count):
        """Login, or other setup, then call this."""
        url = reverse('announcements.delete', locale='es', args=(id,))
        resp = self.client.post(url)
        eq_(resp.status_code, status)
        eq_(Announcement.objects.count(), count)

    def test_delete(self):
        u = UserFactory(is_superuser=1)
        self.client.login(username=u.username, password='******')
        self._delete_test(self.announcement.id, 204, 0)

    def test_leader(self):
        # Use the user that was created in setUp.
        self.client.login(username=self.u.username, password='******')
        self._delete_test(self.announcement.id, 204, 0)

    def test_has_permission(self):
        u = UserFactory()
        add_permission(u, Announcement, 'add_announcement')
        self.client.login(username=u.username, password='******')
        self._delete_test(self.announcement.id, 204, 0)

    def test_no_perms(self):
        u = UserFactory()
        self.client.login(username=u.username, password='******')
        self._delete_test(self.announcement.id, 403, 1)

    def test_anon(self):
        self._delete_test(self.announcement.id, 302, 1)
Пример #9
0
class TestCreateLocaleAnnouncement(TestCase):
    def setUp(self):
        self.locale = LocaleFactory(locale="es")

    def _create_test(self, status, count):
        """Login, or other setup, then call this."""
        url = reverse("announcements.create_for_locale", locale="es")
        resp = self.client.post(
            url,
            {
                "content": "Look at me!",
                "show_after": "2012-01-01",
            },
        )
        eq_(resp.status_code, status)
        eq_(Announcement.objects.count(), count)

    def test_create(self):
        u = UserFactory(is_superuser=1)
        self.client.login(username=u.username, password="******")
        self._create_test(200, 1)

    def test_leader(self):
        u = UserFactory()
        self.locale.leaders.add(u)
        self.locale.save()
        self.client.login(username=u.username, password="******")
        self._create_test(200, 1)

    def test_has_permission(self):
        u = UserFactory()
        add_permission(u, Announcement, "add_announcement")
        self.client.login(username=u.username, password="******")
        self._create_test(200, 1)

    def test_no_perms(self):
        u = UserFactory()
        self.client.login(username=u.username, password="******")
        self._create_test(403, 0)

    def test_anon(self):
        self._create_test(302, 0)
Пример #10
0
class TestCreateLocaleAnnouncement(TestCase):

    def setUp(self):
        self.locale = LocaleFactory(locale='es')

    def _create_test(self, status, count):
        """Login, or other setup, then call this."""
        url = reverse('announcements.create_for_locale', locale='es')
        resp = self.client.post(url, {
            'content': 'Look at me!',
            'show_after': '2012-01-01',
        })
        eq_(resp.status_code, status)
        eq_(Announcement.objects.count(), count)

    def test_create(self):
        u = UserFactory(is_superuser=1)
        self.client.login(username=u.username, password='******')
        self._create_test(200, 1)

    def test_leader(self):
        u = UserFactory()
        self.locale.leaders.add(u)
        self.locale.save()
        self.client.login(username=u.username, password='******')
        self._create_test(200, 1)

    def test_has_permission(self):
        u = UserFactory()
        add_permission(u, Announcement, 'add_announcement')
        self.client.login(username=u.username, password='******')
        self._create_test(200, 1)

    def test_no_perms(self):
        u = UserFactory()
        self.client.login(username=u.username, password='******')
        self._create_test(403, 0)

    def test_anon(self):
        self._create_test(302, 0)
Пример #11
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))
Пример #12
0
    def test_locale_list(self):
        """Verify the locale list renders all locales."""
        lcl = LocaleFactory(locale="es")
        leader = UserFactory()
        lcl.leaders.add(leader)
        reviewer = UserFactory()
        lcl.reviewers.add(reviewer)
        editor = UserFactory()
        lcl.editors.add(editor)

        r = self.client.get(reverse("wiki.locale_details", args=[lcl.locale]))
        eq_(r.status_code, 200)
        doc = pq(r.content)
        leaders = doc("ul.leaders > li")
        eq_(1, len(leaders))
        assert leader.profile.name in leaders.text()
        reviewers = doc("ul.reviewers > li")
        eq_(1, len(reviewers))
        assert reviewer.profile.name in reviewers.text()
        editors = doc("ul.editors > li")
        eq_(1, len(editors))
        assert editor.profile.name in editors.text()
Пример #13
0
 def setUp(self):
     self.locale = LocaleFactory(locale="es")
Пример #14
0
 def setUp(self):
     super(AnnouncementModelTests, self).setUp()
     self.creator = UserFactory()
     self.group = GroupFactory()
     self.locale = LocaleFactory(locale='es')
     self.creator.groups.add(self.group)
Пример #15
0
 def setUp(self):
     self.locale = LocaleFactory(locale='es')
Пример #16
0
 def setUp(self):
     self.locale = LocaleFactory(locale='es')