コード例 #1
0
    def test_foia_detail(self):
        """Test the foia-detail view"""

        foia = FOIARequestFactory()
        get_allowed(
            self.client,
            reverse('foia-detail',
                    kwargs={
                        'idx': foia.pk,
                        'slug': foia.slug,
                        'jurisdiction': foia.jurisdiction.slug,
                        'jidx': foia.jurisdiction.pk
                    }))
コード例 #2
0
ファイル: test_views.py プロジェクト: clytwynec/muckrock
    def test_action_views(self):
        """Test action views"""

        UserFactory(username='******', password='******')
        self.client.login(username='******', password='******')

        foia = FOIARequestFactory(status='payment')
        get_allowed(
            self.client,
            reverse('foia-pay',
                    kwargs={
                        'jurisdiction': foia.jurisdiction.slug,
                        'jidx': foia.jurisdiction.pk,
                        'idx': foia.pk,
                        'slug': foia.slug
                    }))
コード例 #3
0
ファイル: test_views.py プロジェクト: WPMedia/muckrock
    def test_foia_detail(self):
        """Test the foia-detail view"""

        foia = FOIARequestFactory()
        get_allowed(
            self.client,
            reverse(
                "foia-detail",
                kwargs={
                    "idx": foia.pk,
                    "slug": foia.slug,
                    "jurisdiction": foia.jurisdiction.slug,
                    "jidx": foia.jurisdiction.pk,
                },
            ),
        )
コード例 #4
0
ファイル: test_views.py プロジェクト: TJKenney/muckrock
    def test_foia_list_user(self):
        """Test the foia-list-user view"""

        users = UserFactory.create_batch(2)
        FOIARequestFactory.create_batch(4, composer__user=users[0])
        FOIARequestFactory.create_batch(3, composer__user=users[1])

        for user in users:
            response = get_allowed(
                self.client,
                reverse('foia-list-user', kwargs={
                    'user_pk': user.pk,
                })
            )
            nose.tools.eq_(
                set(response.context['object_list']),
                set(
                    FOIARequest.objects.get_viewable(AnonymousUser())
                    .filter(composer__user=user)
                )
            )
            nose.tools.ok_(
                all(
                    foia.user == user
                    for foia in response.context['object_list']
                )
            )
コード例 #5
0
 def test_news_archive_year(self):
     """Should return all articles in the given year"""
     response = get_allowed(
         self.client, reverse("news-archive-year", kwargs={"year": 1999}))
     eq_(len(response.context["object_list"]), 4)
     ok_(
         all(article.pub_date.year == 1999
             for article in response.context["object_list"]))
コード例 #6
0
    def test_foia_list(self):
        """Test the foia-list view"""

        response = get_allowed(self.client, reverse('foia-list'))
        nose.tools.eq_(
            set(response.context['object_list']),
            set(
                FOIARequest.objects.get_viewable(AnonymousUser()).order_by(
                    '-composer__datetime_submitted')[:12]))
コード例 #7
0
 def test_news_archive_month(self):
     """Should return all articel from the given month"""
     response = get_allowed(
         self.client,
         reverse('news-archive-month',
                 kwargs={
                     'year': 1999,
                     'month': 'jan'
                 }))
     eq_(len(response.context['object_list']), 3)
     ok_(
         all(article.pub_date.year == 1999 and article.pub_date.month == 1
             for article in response.context['object_list']))
コード例 #8
0
 def test_news_archive_month(self):
     """Should return all articel from the given month"""
     response = get_allowed(
         self.client,
         reverse("news-archive-month",
                 kwargs={
                     "year": 1999,
                     "month": "jan"
                 }),
     )
     eq_(len(response.context["object_list"]), 3)
     ok_(
         all(article.pub_date.year == 1999 and article.pub_date.month == 1
             for article in response.context["object_list"]))
コード例 #9
0
 def test_news_archive_day(self):
     """Should return all article for the given day"""
     response = get_allowed(
         self.client,
         reverse('news-archive-day',
                 kwargs={
                     'year': 1999,
                     'month': 'jan',
                     'day': 1
                 }))
     eq_(len(response.context['object_list']), 2)
     ok_(
         all(article.pub_date.year == 1999 and article.pub_date.month == 1
             and article.pub_date.day == 1
             for article in response.context['object_list']))
コード例 #10
0
    def test_foia_sorted_list(self):
        """Test sorting on foia-list view"""

        for field in ['title', 'date_submitted']:
            for order in ['asc', 'desc']:
                response = get_allowed(
                    self.client,
                    reverse('foia-list') + '?sort=%s&order=%s' %
                    (field, order))
                nose.tools.eq_(
                    [f.title for f in response.context['object_list']], [
                        f.title
                        for f in sorted(response.context['object_list'],
                                        key=attrgetter(field),
                                        reverse=(order == 'desc'))
                    ])
コード例 #11
0
 def test_news_detail(self):
     """News detail should display the given article"""
     article = ArticleFactory(
         publish=True,
         pub_date=datetime(1999, 1, 1, 12, tzinfo=pytz.utc),
     )
     response = get_allowed(
         self.client,
         reverse('news-detail',
                 kwargs={
                     'year': 1999,
                     'month': 'jan',
                     'day': 1,
                     'slug': article.slug,
                 }))
     eq_(response.context['object'], article)
コード例 #12
0
ファイル: tests.py プロジェクト: clytwynec/muckrock
 def test_news_archive_author(self):
     """Should return all articles for the given author"""
     author = UserFactory()
     ArticleFactory.create_batch(
         3,
         publish=True,
         authors=[author],
         pub_date=timezone.now() - timedelta(1),
     )
     response = get_allowed(
         self.client,
         reverse('news-author', kwargs={
             'username': author.username
         })
     )
     eq_(
         len(response.context['object_list']),
         Article.objects.filter(authors=author).count()
     )
コード例 #13
0
ファイル: test_views.py プロジェクト: WPMedia/muckrock
    def test_foia_sorted_list(self):
        """Test sorting on foia-list view"""

        for field in ["title", "date_submitted"]:
            for order in ["asc", "desc"]:
                response = get_allowed(
                    self.client,
                    reverse("foia-list") + "?sort=%s&order=%s" %
                    (field, order),
                )
                nose.tools.eq_(
                    [f.title for f in response.context["object_list"]],
                    [
                        f.title for f in sorted(
                            response.context["object_list"],
                            key=attrgetter(field),
                            reverse=(order == "desc"),
                        )
                    ],
                )
コード例 #14
0
 def test_news_detail(self):
     """News detail should display the given article"""
     article = ArticleFactory(publish=True,
                              pub_date=datetime(1999,
                                                1,
                                                1,
                                                12,
                                                tzinfo=pytz.utc))
     response = get_allowed(
         self.client,
         reverse(
             "news-detail",
             kwargs={
                 "year": 1999,
                 "month": "jan",
                 "day": 1,
                 "slug": article.slug
             },
         ),
     )
     eq_(response.context["object"], article)
コード例 #15
0
ファイル: test_views.py プロジェクト: TJKenney/muckrock
    def test_feeds(self):
        """Test the RSS feed views"""

        user = UserFactory()
        foias = FOIARequestFactory.create_batch(4, composer__user=user)

        get_allowed(self.client, reverse('foia-submitted-feed'))
        get_allowed(self.client, reverse('foia-done-feed'))
        get_allowed(
            self.client, reverse('foia-feed', kwargs={
                'idx': foias[0].pk
            })
        )
        get_allowed(
            self.client,
            reverse(
                'foia-user-submitted-feed', kwargs={
                    'username': user.username
                }
            )
        )
        get_allowed(
            self.client,
            reverse('foia-user-done-feed', kwargs={
                'username': user.username
            })
        )
        get_allowed(
            self.client,
            reverse('foia-user-feed', kwargs={
                'username': user.username
            })
        )
コード例 #16
0
ファイル: test_views.py プロジェクト: TJKenney/muckrock
 def test_foia_bad_sort(self):
     """Test sorting against a non-existant field"""
     response = get_allowed(self.client, reverse('foia-list') + '?sort=test')
     nose.tools.eq_(response.status_code, 200)
コード例 #17
0
 def test_news_archive(self):
     """Should return all articles"""
     response = get_allowed(self.client, reverse("news-archive"))
     eq_(len(response.context["object_list"]), 5)
コード例 #18
0
 def test_news_index(self):
     """Should redirect to list"""
     get_allowed(self.client, reverse("news-index"))
コード例 #19
0
 def test_feed(self):
     """Should have a feed"""
     get_allowed(self.client, reverse("news-feed"))
コード例 #20
0
ファイル: test_views.py プロジェクト: clytwynec/muckrock
    def test_feeds(self):
        """Test the RSS feed views"""

        get_allowed(self.client, reverse('foia-submitted-feed'))
        get_allowed(self.client, reverse('foia-done-feed'))
コード例 #21
0
 def test_get(self):
     """Test getting the page"""
     FOIARequestFactory(composer__user__profile__organization=self.org)
     get_allowed(self.client, self.url)