Skip to content

Commit

Permalink
job_seekers_views: move anonymous_access tests from apply
Browse files Browse the repository at this point in the history
They belong to job_seekers_views now.
  • Loading branch information
EwenKorr committed Jan 20, 2025
1 parent 51383b7 commit d2b9d02
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
23 changes: 1 addition & 22 deletions tests/www/apply/test_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,8 @@ def test_anonymous_access(self, client):
"apply:start",
"apply:start_hire",
"apply:pending_authorization_for_sender",
"job_seekers_views:check_nir_for_sender",
"job_seekers_views:check_nir_for_job_seeker",
):
if viewname.startswith("apply"):
url = reverse(viewname, kwargs={"company_pk": company.pk})
else:
# Init session (as it would be in apply:start)
session = client.session
session_name = str(uuid.uuid4())
session[session_name] = {
"config": {},
"apply": {"company_pk": company.pk},
}
session.save()
url = reverse(viewname, kwargs={"session_uuid": session_name})
url = reverse(viewname, kwargs={"company_pk": company.pk})
response = client.get(url)
assertRedirects(response, reverse("account_login") + f"?next={url}")

Expand Down Expand Up @@ -3834,10 +3821,6 @@ def _check_only_administrative_allowed(self, client, user):
class TestUpdateJobSeeker(UpdateJobSeekerTestMixin):
FINAL_REDIRECT_VIEW_NAME = "apply:application_jobs"

def test_anonymous_start(self, client):
response = client.get(self.start_url)
assertRedirects(response, add_url_params(reverse("account_login"), {"next": self.start_url}))

def test_as_job_seeker(self, client):
self._check_nothing_permitted(client, self.job_seeker)

Expand Down Expand Up @@ -3976,10 +3959,6 @@ def test_as_company_that_last_step_doesnt_crash_with_direct_access(self, client)
class TestUpdateJobSeekerForHire(UpdateJobSeekerTestMixin):
FINAL_REDIRECT_VIEW_NAME = "job_seekers_views:check_job_seeker_info_for_hire"

def test_anonymous_start(self, client):
response = client.get(self.start_url)
assertRedirects(response, add_url_params(reverse("account_login"), {"next": self.start_url}))

def test_as_job_seeker(self, client):
self._check_nothing_permitted(client, self.job_seeker)

Expand Down
25 changes: 25 additions & 0 deletions tests/www/job_seekers_views/test_create_or_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import uuid

import pytest
from django.template.defaultfilters import urlencode
from django.urls import reverse
from pytest_django.asserts import assertContains, assertRedirects

Expand Down Expand Up @@ -52,6 +53,19 @@ def test_itou_staff_are_not_allowed_to_get_or_create_job_seeker(self, client):
response = client.get(start_url)
assert response.status_code == 403

def test_anonymous_access(self, client):
company = CompanyFactory()

for tunnel in self.TUNNELS:
params = {
"tunnel": tunnel,
"company": company.pk,
"from_url": reverse("companies_views:card", kwargs={"siae_id": company.pk}),
}
start_url = add_url_params(reverse("job_seekers_views:get_or_create_start"), params)
response = client.get(start_url)
assertRedirects(response, reverse("account_login") + f"?next={urlencode(start_url)}")


class TestGetOrCreateForJobSeeker:
def test_start_create_forbidden_for_job_seekers(self, client):
Expand Down Expand Up @@ -363,6 +377,17 @@ def test_itou_staff_are_not_allowed_to_update_job_seeker(self, client):
response = client.get(start_url)
assert response.status_code == 403

def test_anonymous_access(self, client):
job_seeker = JobSeekerFactory()

params = {
"job_seeker": job_seeker.public_id,
"from_url": reverse("dashboard:index"),
}
start_url = add_url_params(reverse("job_seekers_views:update_job_seeker_start"), params)
response = client.get(start_url)
assertRedirects(response, reverse("account_login") + f"?next={urlencode(start_url)}")


class TestUpdateForJobSeeker:
def test_start_update_job_seeker_forbidden(self, client):
Expand Down

0 comments on commit d2b9d02

Please sign in to comment.