Skip to content

Commit

Permalink
Fix job application unarchive transitions tests
Browse files Browse the repository at this point in the history
Clarify the test cases generation, and fix a bunch of issues:
- the transition target name does not need checking, only the from state
- remove duplicate check for unarchiving accepted and prior to hire
  • Loading branch information
francoisfreitag committed Sep 13, 2024
1 parent eee15af commit 8e4478e
Showing 1 changed file with 7 additions and 26 deletions.
33 changes: 7 additions & 26 deletions tests/job_applications/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1694,17 +1694,13 @@ def test_job_application_transitions(transition, from_state):
pytest.param(transition, from_state, id=f"transition={transition.name} from_state={from_state}")
for transition in JobApplicationWorkflow.transitions
for from_state in transition.source
if not (
# Leads to a state that cannot be archived.
{
# Employment relationship between employer and job seeker, it is active.
JobApplicationState.ACCEPTED,
# Employer waits for a prior action before to establish an employment relationship.
JobApplicationState.PRIOR_TO_HIRE,
}
& {from_state.name, transition.target.name}
# Employer transfers to another structure, they likely won’t interact with this job application again.
or JobApplicationWorkflow.TRANSITION_EXTERNAL_TRANSFER == transition.name
if transition.name != JobApplicationWorkflow.TRANSITION_EXTERNAL_TRANSFER
and from_state.name
not in (
# Employment relationship between employer and job seeker, it is active.
JobApplicationState.ACCEPTED,
# Employer waits for a prior action before to establish an employment relationship.
JobApplicationState.PRIOR_TO_HIRE,
)
],
)
Expand All @@ -1721,21 +1717,6 @@ def test_job_application_transition_unarchives(transition, from_state):
assert job_application.archived_at is None


@pytest.mark.parametrize(
"transition_name",
[
JobApplicationWorkflow.TRANSITION_ACCEPT,
JobApplicationWorkflow.TRANSITION_MOVE_TO_PRIOR_TO_HIRE,
],
)
def test_unarchive_job_application(transition_name):
job_application = JobApplicationFactory(state=JobApplicationState.PROCESSING, archived_at=timezone.now())
user = job_application.to_company.members.get()
getattr(job_application, transition_name)(user=user)
job_application.refresh_from_db()
assert job_application.archived_at is None


class JobApplicationXlsxExportTest(TestCase):
def test_xlsx_export_contains_the_necessary_info(self, *args, **kwargs):
create_test_romes_and_appellations(["M1805"], appellations_per_rome=2)
Expand Down

0 comments on commit 8e4478e

Please sign in to comment.