Skip to content

Commit

Permalink
test ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Sep 9, 2024
1 parent 1e1bd6e commit 66e1613
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions lacommunaute/stats/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ class Meta:

class Params:
for_snapshot = factory.Trait(period="week", date=datetime.date(2024, 5, 20))
for_snapshot_older = factory.Trait(period="week", date=datetime.date(2024, 5, 13))
12 changes: 6 additions & 6 deletions lacommunaute/stats/tests/tests_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,18 +355,18 @@ def test_visitors(self, client, db, snapshot):


@pytest.mark.parametrize(
"forum_stat,status_code",
"forum_stats,status_code",
[
(lambda: None, 404),
(lambda: ForumStatFactory(period="week", for_snapshot=True), 302),
(lambda: [ForumStatFactory(for_snapshot=True), ForumStatFactory(for_snapshot_older=True)], 302),
],
)
def test_redirect_to_latest_weekly_stats(client, db, forum_stat, status_code):
forum_stat = forum_stat()
def test_redirect_to_latest_weekly_stats(client, db, forum_stats, status_code):
forum_stats = forum_stats()
response = client.get(reverse("stats:redirect_to_latest_weekly_stats"))
assert response.status_code == status_code
if forum_stat:
if forum_stats:
assert response.url == reverse(
"stats:forum_stat_week_archive",
kwargs={"year": forum_stat.date.year, "week": forum_stat.date.strftime("%W")},
kwargs={"year": forum_stats[0].date.year, "week": forum_stats[0].date.strftime("%W")},
)

0 comments on commit 66e1613

Please sign in to comment.