Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KwikKill committed Nov 25, 2024
1 parent 86f319c commit 3bd129c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
16 changes: 8 additions & 8 deletions insalan/langate/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def test_unauthenticated_user(self):
"""
Tests that the API endpoint refuses to give information without auth
"""
request = self.client.post("/v1/langate/authenticate", format="json")
request = self.client.post("/v1/langate/authenticate/", format="json")
self.assertEqual(request.status_code, 400)

def test_authenticated_user(self):
Expand All @@ -91,7 +91,7 @@ def test_authenticated_user(self):
"username": "limefox",
"password": "bad_pass"
}
reply = self.client.post('/v1/langate/authenticate', data)
reply = self.client.post('/v1/langate/authenticate/', data)
self.assertEqual(reply.status_code, 404)

ser = reply.data
Expand Down Expand Up @@ -124,7 +124,7 @@ def test_no_ongoing_event(self):
"username": "limefox",
"password": "bad_pass"
}
reply = self.client.post('/v1/langate/authenticate', data)
reply = self.client.post('/v1/langate/authenticate/', data)
# No ongoing event triggers a 500
self.assertEqual(reply.status_code, 500)

Expand All @@ -151,7 +151,7 @@ def test_one_ongoing_event(self):
"username": "limefox",
"password": "bad_pass"
}
reply = self.client.post('/v1/langate/authenticate', data)
reply = self.client.post('/v1/langate/authenticate/', data)
self.assertEqual(reply.status_code, 200)

ser = reply.data
Expand Down Expand Up @@ -189,7 +189,7 @@ def test_payment_status_paid(self):
"username": "limefox",
"password": "bad_pass"
}
reply = self.client.post('/v1/langate/authenticate', data)
reply = self.client.post('/v1/langate/authenticate/', data)
self.assertEqual(reply.status_code, 200)

ser = reply.data
Expand Down Expand Up @@ -227,7 +227,7 @@ def test_payment_status_pay_later(self):
"username": "limefox",
"password": "bad_pass"
}
reply = self.client.post('/v1/langate/authenticate', data)
reply = self.client.post('/v1/langate/authenticate/', data)
self.assertEqual(reply.status_code, 200)

ser = reply.data
Expand Down Expand Up @@ -266,7 +266,7 @@ def test_payment_status_contamination(self):
"username": "limefox",
"password": "bad_pass"
}
reply = self.client.post('/v1/langate/authenticate', data)
reply = self.client.post('/v1/langate/authenticate/', data)
self.assertEqual(reply.status_code, 200)

ser = reply.data
Expand Down Expand Up @@ -312,7 +312,7 @@ def test_payment_status_fully_paid(self):
"username": "limefox",
"password": "bad_pass"
}
reply = self.client.post('/v1/langate/authenticate', data)
reply = self.client.post('/v1/langate/authenticate/', data)
self.assertEqual(reply.status_code, 200)

ser = reply.data
Expand Down
4 changes: 2 additions & 2 deletions insalan/mailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def send_email_confirmation(self, user_object: User):
email = EmailMessage(
insalan.settings.EMAIL_SUBJECT_PREFIX + _("Confirmez votre courriel"),
_("Confirmez votre adresse de courriel en cliquant sur ") +
f"{insalan.settings.PROTOCOL}://{insalan.settings.WEBSITE_HOST}/verification/{user}/{token}",
f"{insalan.settings.PROTOCOL}://{insalan.settings.WEBSITE_HOST}/verification/{user}/{token}/",
self.mail_from,
[user_object.email],
connection=connection,
Expand Down Expand Up @@ -94,7 +94,7 @@ def send_password_reset(self, user_object: User):
"pour votre compte. Si vous êtes à l'origine de cette demande, "
"vous pouvez cliquer sur le lien suivant: "
) +
f"{insalan.settings.PROTOCOL}://{insalan.settings.WEBSITE_HOST}/reset-password/{user}/{token}",
f"{insalan.settings.PROTOCOL}://{insalan.settings.WEBSITE_HOST}/reset-password/{user}/{token}/",
self.mail_from,
[user_object.email],
connection=connection,
Expand Down
16 changes: 8 additions & 8 deletions insalan/tournament/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ def test_not_found(self):
not_used = max(candidates) + 1

request = self.client.get(
f"/v1/tournament/tournament/{not_used}/full", format="sjon"
f"/v1/tournament/tournament/{not_used}/full/", format="sjon"
)
self.assertEqual(request.status_code, 404)

Expand Down Expand Up @@ -1395,7 +1395,7 @@ def test_year_group_empty(self):
"""Test what happens when events are in the database but we query an empty year"""
self.create_multiple_events()

request = self.client.get("/v1/tournament/event/year/2020", format="json")
request = self.client.get("/v1/tournament/event/year/2020/", format="json")

self.assertEqual(request.status_code, 200)
self.assertEqual(len(request.data), 0)
Expand All @@ -1404,7 +1404,7 @@ def test_year_one_found(self):
"""Test what happens when one event is found"""
self.create_multiple_events()

request = self.client.get("/v1/tournament/event/year/2018", format="json")
request = self.client.get("/v1/tournament/event/year/2018/", format="json")

self.assertEqual(request.status_code, 200)
self.assertEqual(len(request.data), 1)
Expand All @@ -1413,15 +1413,15 @@ def test_year_two_found(self):
"""Test what happens when multiple events are found"""
self.create_multiple_events()

request = self.client.get("/v1/tournament/event/year/2019", format="json")
request = self.client.get("/v1/tournament/event/year/2019/", format="json")
self.assertEqual(request.status_code, 200)
self.assertEqual(len(request.data), 2)

def test_year_garbage(self):
"""Test that if you put anything but a year it's not recognized"""
self.create_multiple_events()

request = self.client.get("/v1/tournament/event/year/00d1686a", format="json")
request = self.client.get("/v1/tournament/event/year/00d1686a/", format="json")
self.assertEqual(request.status_code, 404)

def test_deref_not_found(self):
Expand All @@ -1431,7 +1431,7 @@ def test_deref_not_found(self):
not_assigned_list = [1]
not_assigned = max(not_assigned_list) + 1
request = self.client.get(
f"/v1/tournament/event/{not_assigned}/tournaments", format="json"
f"/v1/tournament/event/{not_assigned}/tournaments/", format="json"
)

self.assertEqual(request.status_code, 404)
Expand All @@ -1449,7 +1449,7 @@ def test_deref_not_announced(self):
)

request = self.client.get(
f"/v1/tournament/event/{evobj.id}/tournaments", format="json"
f"/v1/tournament/event/{evobj.id}/tournaments/", format="json"
)

self.assertEqual(request.status_code, 200)
Expand Down Expand Up @@ -1485,7 +1485,7 @@ def test_deref(self):
)

request = self.client.get(
f"/v1/tournament/event/{evobj.id}/tournaments", format="json"
f"/v1/tournament/event/{evobj.id}/tournaments/", format="json"
)

self.assertEqual(request.status_code, 200)
Expand Down
2 changes: 1 addition & 1 deletion insalan/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
path("v1/tournament/", include("insalan.tournament.urls")),
path("v1/user/", include("insalan.user.urls")),
path("v1/tickets/", include("insalan.tickets.urls")),
path("v1/langate/authenticate", langate_views.LangateUserView.as_view()),
path("v1/langate/authenticate/", langate_views.LangateUserView.as_view()),
path("v1/content/", include("insalan.cms.urls")),
path("v1/admin/", admin.site.urls),
path("v1/payment/", include("insalan.payment.urls")),
Expand Down
20 changes: 10 additions & 10 deletions insalan/user/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def test_register_can_confirm_email(self):

self.assertFalse(User.objects.get(username=data["username"]).is_email_active())
match = re.match(
".*https?://[^ ]*/(?P<user_pk>[^ /]*)/(?P<token>[^ /]*)",
".*https?://[^ ]*/(?P<user_pk>[^ /]*)/(?P<token>[^ /]*)/",
mail.outbox[0].body,
)

Expand All @@ -318,7 +318,7 @@ def test_register_can_confirm_email(self):

self.assertEqual(match_user_pk, user_pk)

request = self.client.get(f"/v1/user/confirm/{match_user_pk}/{token}")
request = self.client.get(f"/v1/user/confirm/{match_user_pk}/{token}/")
self.assertEqual(request.status_code, 200)

self.assertTrue(User.objects.get(username=data["username"]).is_email_active())
Expand All @@ -339,17 +339,17 @@ def test_can_confirm_email_only_once(self):
self.client.post("/v1/user/register/", data, format="json")
user_pk = User.objects.get(username=data["username"]).pk
match = re.match(
".*https?://[^ ]*/(?P<user_pk>[^ /]*)/(?P<token>[^ /]*)",
".*https?://[^ ]*/(?P<user_pk>[^ /]*)/(?P<token>[^ /]*)/",
mail.outbox[0].body,
)

match_user_pk = match["user_pk"]
token = match["token"]

request = self.client.get(f"/v1/user/confirm/{match_user_pk}/{token}")
request = self.client.get(f"/v1/user/confirm/{match_user_pk}/{token}/")
self.assertEqual(request.status_code, 200)

request = self.client.get(f"/v1/user/confirm/{match_user_pk}/{token}")
request = self.client.get(f"/v1/user/confirm/{match_user_pk}/{token}/")
self.assertEqual(request.status_code, 400)

def test_confirmation_email_is_token_checked(self):
Expand All @@ -367,7 +367,7 @@ def test_confirmation_email_is_token_checked(self):

self.client.post("/v1/user/register/", data, format="json")
match = re.match(
".*https?://[^ ]*/(?P<username>[^ /]*)/(?P<token>[^ /]*)",
".*https?://[^ ]*/(?P<username>[^ /]*)/(?P<token>[^ /]*)/",
mail.outbox[0].body,
)

Expand All @@ -377,7 +377,7 @@ def test_confirmation_email_is_token_checked(self):
token[-1] = "x"
token = "".join(token)

request = self.client.get(f"/v1/user/confirm/{username}/{token}")
request = self.client.get(f"/v1/user/confirm/{username}/{token}/")

self.assertEqual(request.status_code, 400)

Expand Down Expand Up @@ -551,7 +551,7 @@ def test_can_reset_password(self):

match = re.search(
# "https?://[^ ]*/password-reset/ask[^ ]*",
".*https?://[^ ]*/(?P<user_pk>[^ &]*)/(?P<token>[^ /]*)",
".*https?://[^ ]*/(?P<user_pk>[^ &]*)/(?P<token>[^ /]*)/",
mail.outbox[0].body,
)

Expand Down Expand Up @@ -599,7 +599,7 @@ def test_can_reset_password_only_once(self):

match = re.search(
# "https?://[^ ]*/password-reset/ask[^ ]*",
".*https?://[^ ]*/(?P<user_pk>[^ &]*)/(?P<token>[^ /]*)",
".*https?://[^ ]*/(?P<user_pk>[^ &]*)/(?P<token>[^ /]*)/",
mail.outbox[0].body,
)

Expand Down Expand Up @@ -642,7 +642,7 @@ def test_password_reset_is_token_checked(self):
self.client.post("/v1/user/password-reset/ask/", data, format="json")

match = re.search(
".*https?://[^ ]*/(?P<username>[^ &]*)/(?P<token>[^ /]*)",
".*https?://[^ ]*/(?P<username>[^ &]*)/(?P<token>[^ /]*)/",
mail.outbox[0].body,
)

Expand Down

0 comments on commit 3bd129c

Please sign in to comment.