diff --git a/itou/employee_record/management/commands/archive_employee_records.py b/itou/employee_record/management/commands/archive_employee_records.py
index b7c7fba082..458bf71a69 100644
--- a/itou/employee_record/management/commands/archive_employee_records.py
+++ b/itou/employee_record/management/commands/archive_employee_records.py
@@ -26,7 +26,7 @@ def handle(self, *, wet_run, **options):
self.stdout.write(f"Archiving {employee_record.pk=}")
if wet_run:
try:
- employee_record.update_as_archived()
+ employee_record.archive()
except Exception as ex:
self.stdout.write(f"Can't archive {employee_record.pk=} {ex=}")
else:
diff --git a/itou/employee_record/management/commands/transfer_employee_records.py b/itou/employee_record/management/commands/transfer_employee_records.py
index 64f55825f6..f6d068805d 100644
--- a/itou/employee_record/management/commands/transfer_employee_records.py
+++ b/itou/employee_record/management/commands/transfer_employee_records.py
@@ -56,9 +56,7 @@ def _upload_batch_file(self, sftp: paramiko.SFTPClient, employee_records: list[E
# and store in which file they have been sent
renderer = JSONRenderer()
for idx, employee_record in enumerate(employee_records, 1):
- employee_record.update_as_sent(
- remote_path, idx, renderer.render(batch_data["lignesTelechargement"][idx - 1])
- )
+ employee_record.sent(remote_path, idx, renderer.render(batch_data["lignesTelechargement"][idx - 1]))
def _parse_feedback_file(self, feedback_file: str, batch: dict, dry_run: bool) -> None:
"""
@@ -97,7 +95,7 @@ def _parse_feedback_file(self, feedback_file: str, batch: dict, dry_run: bool) -
archived_json = JSONRenderer().render(raw_employee_record)
if processing_code == EmployeeRecord.ASP_PROCESSING_SUCCESS_CODE: # Processed by ASP
if not dry_run:
- employee_record.update_as_processed(processing_code, processing_label, archived_json)
+ employee_record.process(processing_code, processing_label, archived_json)
else:
self.stdout.write(f"DRY-RUN: Accepted {employee_record=}, {processing_code=}, {processing_label=}")
else: # Rejected by ASP
@@ -105,9 +103,7 @@ def _parse_feedback_file(self, feedback_file: str, batch: dict, dry_run: bool) -
# One special case added for support concerns:
# 3436 processing code are automatically converted as PROCESSED
if processing_code == EmployeeRecord.ASP_DUPLICATE_ERROR_CODE:
- employee_record.update_as_processed(
- processing_code, processing_label, archived_json, as_duplicate=True
- )
+ employee_record.process(processing_code, processing_label, archived_json, as_duplicate=True)
# If the ASP mark the employee record as duplicate,
# and there is a suspension or a prolongation for the associated approval,
@@ -127,7 +123,7 @@ def _parse_feedback_file(self, feedback_file: str, batch: dict, dry_run: bool) -
continue
- employee_record.update_as_rejected(processing_code, processing_label, archived_json)
+ employee_record.reject(processing_code, processing_label, archived_json)
else:
self.stdout.write(f"DRY-RUN: Rejected {employee_record=}, {processing_code=}, {processing_label=}")
diff --git a/itou/employee_record/management/commands/transfer_employee_records_updates.py b/itou/employee_record/management/commands/transfer_employee_records_updates.py
index 9f1e58ea19..6e7265350b 100644
--- a/itou/employee_record/management/commands/transfer_employee_records_updates.py
+++ b/itou/employee_record/management/commands/transfer_employee_records_updates.py
@@ -62,9 +62,7 @@ def _upload_batch_file(
renderer = JSONRenderer()
for idx, notification in enumerate(notifications, 1):
- notification.update_as_sent(
- remote_path, idx, renderer.render(batch_data["lignesTelechargement"][idx - 1])
- )
+ notification.sent(remote_path, idx, renderer.render(batch_data["lignesTelechargement"][idx - 1]))
def _parse_feedback_file(self, feedback_file: str, batch: dict, dry_run: bool) -> None:
"""
@@ -102,12 +100,12 @@ def _parse_feedback_file(self, feedback_file: str, batch: dict, dry_run: bool) -
archived_json = JSONRenderer().render(employee_record)
if processing_code == EmployeeRecordUpdateNotification.ASP_PROCESSING_SUCCESS_CODE: # Processed by ASP
if not dry_run:
- notification.update_as_processed(processing_code, processing_label, archived_json)
+ notification.process(processing_code, processing_label, archived_json)
else:
self.stdout.write(f"DRY-RUN: Processed {notification}, {processing_code=}, {processing_label=}")
else: # Rejected by ASP
if not dry_run:
- notification.update_as_rejected(processing_code, processing_label, archived_json)
+ notification.reject(processing_code, processing_label, archived_json)
else:
self.stdout.write(f"DRY-RUN: Rejected {notification}: {processing_code=}, {processing_label=}")
diff --git a/itou/employee_record/models.py b/itou/employee_record/models.py
index 2dae3ca7d5..f09c8c5cb0 100644
--- a/itou/employee_record/models.py
+++ b/itou/employee_record/models.py
@@ -289,8 +289,8 @@ def _fill_denormalized_fields(self):
# Business methods
- @xwf_models.transition(EmployeeRecordTransition.READY)
- def update_as_ready(self):
+ @xwf_models.transition()
+ def ready(self):
"""
Prepare the employee record for transmission
"""
@@ -310,8 +310,8 @@ def update_as_ready(self):
# To prevent some ASP processing errors, we do a refresh on some mutable fields.
self._fill_denormalized_fields()
- @xwf_models.transition(EmployeeRecordTransition.SENT)
- def update_as_sent(self, asp_filename, line_number, archive):
+ @xwf_models.transition()
+ def sent(self, asp_filename, line_number, archive):
"""
An employee record is sent to ASP via a JSON file,
The file name is stored for further feedback processing (also done via a file)
@@ -319,16 +319,16 @@ def update_as_sent(self, asp_filename, line_number, archive):
self.clean()
self.set_asp_batch_information(asp_filename, line_number, archive)
- @xwf_models.transition(EmployeeRecordTransition.REJECT)
- def update_as_rejected(self, code, label, archive):
+ @xwf_models.transition()
+ def reject(self, code, label, archive):
"""
Update status after an ASP rejection of the employee record
"""
self.clean()
self.set_asp_processing_information(code, label, archive)
- @xwf_models.transition(EmployeeRecordTransition.PROCESS)
- def update_as_processed(self, code, label, archive, *, as_duplicate=False):
+ @xwf_models.transition()
+ def process(self, code, label, archive, *, as_duplicate=False):
if as_duplicate and code != self.ASP_DUPLICATE_ERROR_CODE:
raise ValueError(f"Code needs to be {self.ASP_DUPLICATE_ERROR_CODE} and not {code} when {as_duplicate=}")
@@ -339,16 +339,12 @@ def update_as_processed(self, code, label, archive, *, as_duplicate=False):
code, label if not as_duplicate else "Statut forcé suite à doublon ASP", archive
)
- @xwf_models.transition(EmployeeRecordTransition.DISABLE)
- def update_as_disabled(self):
- pass
-
- @xwf_models.transition(EmployeeRecordTransition.ENABLE)
- def update_as_new(self):
+ @xwf_models.transition()
+ def enable(self):
self._fill_denormalized_fields()
- @xwf_models.transition(EmployeeRecordTransition.ARCHIVE)
- def update_as_archived(self):
+ @xwf_models.transition()
+ def archive(self):
# We only archive an employee record when the job seeker's approval is expired and can no longer be prolonged
if self.job_application.approval.is_valid() or self.job_application.approval.can_be_prolonged:
raise xwf_models.InvalidTransitionError()
@@ -588,14 +584,14 @@ class Meta(ASPExchangeInformation.Meta):
def __repr__(self):
return f"<{type(self).__name__} pk={self.pk}>"
- @xwf_models.transition(EmployeeRecordTransition.SENT)
- def update_as_sent(self, filename, line_number, archive):
+ @xwf_models.transition()
+ def sent(self, filename, line_number, archive):
self.set_asp_batch_information(filename, line_number, archive)
- @xwf_models.transition(EmployeeRecordTransition.REJECT)
- def update_as_rejected(self, code, label, archive):
+ @xwf_models.transition()
+ def reject(self, code, label, archive):
self.set_asp_processing_information(code, label, archive)
- @xwf_models.transition(EmployeeRecordTransition.PROCESS)
- def update_as_processed(self, code, label, archive):
+ @xwf_models.transition()
+ def process(self, code, label, archive):
self.set_asp_processing_information(code, label, archive)
diff --git a/itou/templates/employee_record/includes/list_item.html b/itou/templates/employee_record/includes/list_item.html
index 65cb01317f..c7305d6ca2 100644
--- a/itou/templates/employee_record/includes/list_item.html
+++ b/itou/templates/employee_record/includes/list_item.html
@@ -122,7 +122,7 @@
- {% if employee_record.update_as_disabled.is_available %}
+ {% if employee_record.disable.is_available %}
Désactiver
diff --git a/itou/www/employee_record_views/views.py b/itou/www/employee_record_views/views.py
index 63b570fa62..5f90c55cff 100644
--- a/itou/www/employee_record_views/views.py
+++ b/itou/www/employee_record_views/views.py
@@ -422,7 +422,7 @@ def create_step_5(request, job_application_id, template_name="employee_record/cr
if request.method == "POST":
back_url = f'{reverse("employee_record_views:list")}?status={employee_record.status}'
- employee_record.update_as_ready()
+ employee_record.ready()
toast_title, toast_message = (
"La création de cette fiche salarié est terminée",
"Vous pouvez suivre l'avancement de son traitement par l'ASP en sélectionnant les différents statuts.",
@@ -482,12 +482,12 @@ def disable(request, employee_record_id, template_name="employee_record/disable.
back_url = f'{reverse("employee_record_views:list")}?status={employee_record.status}'
- if not employee_record.update_as_disabled.is_available():
+ if not employee_record.disable.is_available():
messages.error(request, EmployeeRecord.ERROR_EMPLOYEE_RECORD_INVALID_STATE)
return HttpResponseRedirect(back_url)
if request.method == "POST" and request.POST.get("confirm") == "true":
- employee_record.update_as_disabled()
+ employee_record.disable()
messages.success(request, "La fiche salarié a bien été désactivée.", extra_tags="toast")
return HttpResponseRedirect(back_url)
@@ -520,7 +520,7 @@ def reactivate(request, employee_record_id, template_name="employee_record/react
if request.method == "POST" and request.POST.get("confirm") == "true":
try:
- employee_record.update_as_new()
+ employee_record.enable()
messages.success(request, "La fiche salarié a bien été réactivée.")
return HttpResponseRedirect(back_url)
except ValidationError as ex:
diff --git a/tests/api/employee_record_api/tests.py b/tests/api/employee_record_api/tests.py
index 19ad25e79d..79eb6e5f7d 100644
--- a/tests/api/employee_record_api/tests.py
+++ b/tests/api/employee_record_api/tests.py
@@ -81,7 +81,7 @@ def setup_method(self):
# We only care about status filtering: no coherence check on ASP return values
job_application = JobApplicationWithCompleteJobSeekerProfileFactory()
self.employee_record = EmployeeRecord.from_job_application(job_application)
- self.employee_record.update_as_ready()
+ self.employee_record.ready()
self.siae = job_application.to_company
self.employer = self.siae.members.first()
@@ -101,7 +101,7 @@ def test_fetch_employee_record_list(self, api_client, mocker, faker):
# Get list without filtering by status (PROCESSED)
# note: there is no way to create a processed employee record
# (and this is perfectly normal)
- self.employee_record.update_as_sent(faker.asp_batch_filename(), 1, None)
+ self.employee_record.sent(faker.asp_batch_filename(), 1, None)
process_code, process_message = "0000", "La ligne de la fiche salarié a été enregistrée avec succès."
# There should be no result at this point
@@ -111,7 +111,7 @@ def test_fetch_employee_record_list(self, api_client, mocker, faker):
result = response.json()
assert len(result.get("results")) == 0
- self.employee_record.update_as_processed(process_code, process_message, "{}")
+ self.employee_record.process(process_code, process_message, "{}")
response = api_client.get(ENDPOINT_URL, format="json")
assert response.status_code == 200
@@ -122,7 +122,7 @@ def test_fetch_employee_record_list(self, api_client, mocker, faker):
# status = SENT
job_application = JobApplicationWithCompleteJobSeekerProfileFactory(to_company=self.siae)
employee_record_sent = EmployeeRecord.from_job_application(job_application=job_application)
- employee_record_sent.update_as_ready()
+ employee_record_sent.ready()
# There should be no result at this point
response = api_client.get(ENDPOINT_URL + "?status=SENT", format="json")
@@ -131,7 +131,7 @@ def test_fetch_employee_record_list(self, api_client, mocker, faker):
result = response.json()
assert len(result.get("results")) == 0
- employee_record_sent.update_as_sent(faker.asp_batch_filename(), 1, None)
+ employee_record_sent.sent(faker.asp_batch_filename(), 1, None)
response = api_client.get(ENDPOINT_URL + "?status=SENT", format="json")
assert response.status_code == 200
@@ -142,8 +142,8 @@ def test_fetch_employee_record_list(self, api_client, mocker, faker):
# status = REJECTED
job_application = JobApplicationWithCompleteJobSeekerProfileFactory(to_company=self.siae)
employee_record_rejected = EmployeeRecord.from_job_application(job_application=job_application)
- employee_record_rejected.update_as_ready()
- employee_record_rejected.update_as_sent(faker.asp_batch_filename(), 1, None)
+ employee_record_rejected.ready()
+ employee_record_rejected.sent(faker.asp_batch_filename(), 1, None)
# There should be no result at this point
response = api_client.get(ENDPOINT_URL + "?status=REJECTED", format="json")
@@ -153,7 +153,7 @@ def test_fetch_employee_record_list(self, api_client, mocker, faker):
assert len(result.get("results")) == 0
err_code, err_message = "12", "JSON Invalide"
- employee_record_rejected.update_as_rejected(err_code, err_message, None)
+ employee_record_rejected.reject(err_code, err_message, None)
# Status case is not important
response = api_client.get(ENDPOINT_URL + "?status=rEjEcTeD", format="json")
@@ -198,7 +198,7 @@ def test_status_parameter(self, api_client, mocker):
)
job_application = JobApplicationWithCompleteJobSeekerProfileFactory()
employee_record = EmployeeRecord.from_job_application(job_application)
- employee_record.update_as_ready()
+ employee_record.ready()
member = employee_record.job_application.to_company.members.first()
api_client.force_login(member)
@@ -223,14 +223,14 @@ def test_status_array_parameter(self, api_client, mocker, faker):
)
job_application_1 = JobApplicationWithCompleteJobSeekerProfileFactory()
employee_record = EmployeeRecord.from_job_application(job_application_1)
- employee_record.update_as_ready()
+ employee_record.ready()
job_application_2 = JobApplicationWithCompleteJobSeekerProfileFactory(
to_company=employee_record.job_application.to_company
)
employee_record = EmployeeRecord.from_job_application(job_application_2)
- employee_record.update_as_ready()
- employee_record.update_as_sent(faker.asp_batch_filename(), 1, None)
+ employee_record.ready()
+ employee_record.sent(faker.asp_batch_filename(), 1, None)
member = employee_record.job_application.to_company.members.first()
api_client.force_login(member)
@@ -345,7 +345,7 @@ def test_chain_parameters(self, api_client, mocker):
job_application_2 = JobApplicationWithCompleteJobSeekerProfileFactory(to_company=job_application_1.to_company)
employee_record_2 = EmployeeRecord.from_job_application(job_application_2)
employee_record_2.created_at = ancient_ts
- employee_record_2.update_as_ready()
+ employee_record_2.ready()
member = employee_record_1.job_application.to_company.members.first()
diff --git a/tests/employee_record/test_models.py b/tests/employee_record/test_models.py
index 799057e129..ad9dc60d4a 100644
--- a/tests/employee_record/test_models.py
+++ b/tests/employee_record/test_models.py
@@ -109,7 +109,7 @@ def test_prepare_successful(self, _mock):
"""
job_application = JobApplicationWithCompleteJobSeekerProfileFactory()
employee_record = EmployeeRecord.from_job_application(job_application)
- employee_record.update_as_ready()
+ employee_record.ready()
job_seeker = job_application.job_seeker
assert job_seeker.jobseeker_profile is not None
@@ -130,9 +130,9 @@ def test_prepare_failed_geoloc(self):
with pytest.raises(ValidationError):
employee_record = EmployeeRecord.from_job_application(job_application)
- employee_record.update_as_ready()
+ employee_record.ready()
- def test_update_as_ready_fill_denormalized_fields(self):
+ def test_ready_fill_denormalized_fields(self):
job_application = JobApplicationWithCompleteJobSeekerProfileFactory()
employee_record = EmployeeRecord.from_job_application(job_application)
@@ -147,7 +147,7 @@ def test_update_as_ready_fill_denormalized_fields(self):
assert employee_record.asp_id == old_siae.convention.asp_id
assert employee_record.approval_number == old_approval.number
- employee_record.update_as_ready()
+ employee_record.ready()
employee_record.refresh_from_db()
assert employee_record.siret == new_company.siret
@@ -340,7 +340,7 @@ def setup_method(self, mocker):
job_application = JobApplicationWithCompleteJobSeekerProfileFactory()
employee_record = EmployeeRecord.from_job_application(job_application)
self.employee_record = employee_record
- self.employee_record.update_as_ready()
+ self.employee_record.ready()
def test_state_ready(
self,
@@ -348,29 +348,29 @@ def test_state_ready(
assert self.employee_record.status == Status.READY
def test_state_sent(self, faker):
- self.employee_record.update_as_sent(faker.asp_batch_filename(), 42, "{}")
+ self.employee_record.sent(faker.asp_batch_filename(), 42, "{}")
assert self.employee_record.status == Status.SENT
assert self.employee_record.asp_batch_line_number == 42
assert self.employee_record.archived_json == {}
def test_state_rejected(self, faker):
- self.employee_record.update_as_sent(faker.asp_batch_filename(), 1, None)
+ self.employee_record.sent(faker.asp_batch_filename(), 1, None)
- self.employee_record.update_as_rejected("12", "JSON Invalide", "{}")
+ self.employee_record.reject("12", "JSON Invalide", "{}")
assert self.employee_record.status == Status.REJECTED
assert self.employee_record.asp_processing_code == "12"
assert self.employee_record.asp_processing_label == "JSON Invalide"
assert self.employee_record.archived_json == {}
def test_state_processed(self, faker):
- self.employee_record.update_as_sent(faker.asp_batch_filename(), 1, None)
+ self.employee_record.sent(faker.asp_batch_filename(), 1, None)
process_code, process_message = (
EmployeeRecord.ASP_PROCESSING_SUCCESS_CODE,
"La ligne de la fiche salarié a été enregistrée avec succès.",
)
- self.employee_record.update_as_processed(process_code, process_message, "{}")
+ self.employee_record.process(process_code, process_message, "{}")
assert self.employee_record.status == Status.PROCESSED
assert self.employee_record.asp_processing_code == process_code
@@ -378,13 +378,13 @@ def test_state_processed(self, faker):
assert self.employee_record.archived_json == {}
def test_state_processed_when_archive_is_none(self, faker):
- self.employee_record.update_as_sent(faker.asp_batch_filename(), 1, None)
+ self.employee_record.sent(faker.asp_batch_filename(), 1, None)
process_code, process_message = (
EmployeeRecord.ASP_PROCESSING_SUCCESS_CODE,
"La ligne de la fiche salarié a été enregistrée avec succès.",
)
- self.employee_record.update_as_processed(process_code, process_message, None)
+ self.employee_record.process(process_code, process_message, None)
assert self.employee_record.status == Status.PROCESSED
assert self.employee_record.asp_processing_code == process_code
@@ -392,13 +392,13 @@ def test_state_processed_when_archive_is_none(self, faker):
assert self.employee_record.archived_json is None
def test_state_processed_when_archive_is_empty(self, faker):
- self.employee_record.update_as_sent(faker.asp_batch_filename(), 1, None)
+ self.employee_record.sent(faker.asp_batch_filename(), 1, None)
process_code, process_message = (
EmployeeRecord.ASP_PROCESSING_SUCCESS_CODE,
"La ligne de la fiche salarié a été enregistrée avec succès.",
)
- self.employee_record.update_as_processed(process_code, process_message, "")
+ self.employee_record.process(process_code, process_message, "")
assert self.employee_record.status == Status.PROCESSED
assert self.employee_record.asp_processing_code == process_code
@@ -406,13 +406,13 @@ def test_state_processed_when_archive_is_empty(self, faker):
assert self.employee_record.archived_json == ""
def test_state_processed_when_archive_is_not_json(self, faker):
- self.employee_record.update_as_sent(faker.asp_batch_filename(), 1, None)
+ self.employee_record.sent(faker.asp_batch_filename(), 1, None)
process_code, process_message = (
EmployeeRecord.ASP_PROCESSING_SUCCESS_CODE,
"La ligne de la fiche salarié a été enregistrée avec succès.",
)
- self.employee_record.update_as_processed(process_code, process_message, "whatever")
+ self.employee_record.process(process_code, process_message, "whatever")
assert self.employee_record.status == Status.PROCESSED
assert self.employee_record.asp_processing_code == process_code
@@ -422,13 +422,13 @@ def test_state_processed_when_archive_is_not_json(self, faker):
def test_state_disabled(self, faker):
# Employee record in READY state can't be disabled
with pytest.raises(xworkflows.InvalidTransitionError):
- self.employee_record.update_as_disabled()
+ self.employee_record.disable()
assert self.employee_record.status == Status.READY
# Employee record in SENT state can't be disabled
- self.employee_record.update_as_sent(faker.asp_batch_filename(), 1, None)
+ self.employee_record.sent(faker.asp_batch_filename(), 1, None)
with pytest.raises(xworkflows.InvalidTransitionError):
- self.employee_record.update_as_disabled()
+ self.employee_record.disable()
assert self.employee_record.status == Status.SENT
# Employee record in ACCEPTED state can be disabled
@@ -436,8 +436,8 @@ def test_state_disabled(self, faker):
EmployeeRecord.ASP_PROCESSING_SUCCESS_CODE,
"La ligne de la fiche salarié a été enregistrée avec succès.",
)
- self.employee_record.update_as_processed(process_code, process_message, "{}")
- self.employee_record.update_as_disabled()
+ self.employee_record.process(process_code, process_message, "{}")
+ self.employee_record.disable()
assert self.employee_record.status == Status.DISABLED
# Employee record in DISABLED state block creating a new one
@@ -445,38 +445,38 @@ def test_state_disabled(self, faker):
EmployeeRecord.from_job_application(self.employee_record.job_application)
# Employee record in NEW state can be disabled
- self.employee_record.update_as_new()
+ self.employee_record.enable()
assert self.employee_record.status == Status.NEW
- self.employee_record.update_as_disabled()
+ self.employee_record.disable()
assert self.employee_record.status == Status.DISABLED
def test_state_disabled_with_reject(self, faker):
- self.employee_record.update_as_sent(faker.asp_batch_filename(), 1, None)
+ self.employee_record.sent(faker.asp_batch_filename(), 1, None)
- self.employee_record.update_as_rejected("12", "JSON Invalide", None)
- self.employee_record.update_as_disabled()
+ self.employee_record.reject("12", "JSON Invalide", None)
+ self.employee_record.disable()
assert self.employee_record.status == Status.DISABLED
def test_reactivate(self, faker):
- self.employee_record.update_as_sent(faker.unique.asp_batch_filename(), 1, None)
+ self.employee_record.sent(faker.unique.asp_batch_filename(), 1, None)
process_code = EmployeeRecord.ASP_PROCESSING_SUCCESS_CODE
process_message = "La ligne de la fiche salarié a été enregistrée avec succès."
archive_first = '{"libelleTraitement":"La ligne de la fiche salarié a été enregistrée avec succès [1]."}'
- self.employee_record.update_as_processed(process_code, process_message, archive_first)
- self.employee_record.update_as_disabled()
+ self.employee_record.process(process_code, process_message, archive_first)
+ self.employee_record.disable()
assert self.employee_record.status == Status.DISABLED
# Employee record in DISABLE state can be reactivate (set state NEW)
- self.employee_record.update_as_new()
+ self.employee_record.enable()
assert self.employee_record.status == Status.NEW
# Employee record can now be changed to the ready state
- self.employee_record.update_as_ready()
+ self.employee_record.ready()
assert self.employee_record.status == Status.READY
filename_second = faker.unique.asp_batch_filename()
archive_second = '{"libelleTraitement":"La ligne de la fiche salarié a été enregistrée avec succès [2]."}'
- self.employee_record.update_as_sent(filename_second, 1, archive_second)
+ self.employee_record.sent(filename_second, 1, archive_second)
assert self.employee_record.asp_batch_file == filename_second
assert self.employee_record.archived_json == json.loads(archive_second)
@@ -485,7 +485,7 @@ def test_reactivate(self, faker):
"La ligne de la fiche salarié a été enregistrée avec succès.",
)
archive_third = '{"libelleTraitement":"La ligne de la fiche salarié a été enregistrée avec succès [3]."}'
- self.employee_record.update_as_processed(process_code, process_message, archive_third)
+ self.employee_record.process(process_code, process_message, archive_third)
assert self.employee_record.asp_batch_file == filename_second
assert self.employee_record.archived_json == json.loads(archive_third)
@@ -496,16 +496,16 @@ def test_reactivate_when_the_siae_has_changed(self, faker):
assert self.employee_record.siret == old_company.siret
assert self.employee_record.asp_id == old_company.convention.asp_id
- self.employee_record.update_as_sent(faker.unique.asp_batch_filename(), 1, None)
- self.employee_record.update_as_processed("", "", None)
- self.employee_record.update_as_disabled()
+ self.employee_record.sent(faker.unique.asp_batch_filename(), 1, None)
+ self.employee_record.process("", "", None)
+ self.employee_record.disable()
# Change SIAE
self.employee_record.job_application.to_company = new_company
self.employee_record.job_application.save()
self.employee_record.refresh_from_db()
# Reactivate the employee record
- self.employee_record.update_as_new()
+ self.employee_record.enable()
assert self.employee_record.siret == new_company.siret
assert self.employee_record.asp_id == new_company.convention.asp_id
@@ -516,7 +516,7 @@ def test_state_archived(self):
# Can't archive while the approval is valid
assert approval.is_valid()
with pytest.raises(xworkflows.InvalidTransitionError):
- self.employee_record.update_as_archived()
+ self.employee_record.archive()
# Make the approval expires
approval.start_at = timezone.localdate() - timedelta(days=Approval.DEFAULT_APPROVAL_DAYS)
@@ -524,7 +524,7 @@ def test_state_archived(self):
approval.save()
assert not approval.is_valid()
- self.employee_record.update_as_archived()
+ self.employee_record.archive()
# Check correct status and empty archived JSON
assert self.employee_record.status == Status.ARCHIVED
assert self.employee_record.archived_json is None
@@ -547,7 +547,7 @@ def test_processed_as_duplicate(self):
asp_processing_code="3436",
asp_processing_label="Meh Meh Meh",
)
- employee_record_code_3436.update_as_processed(
+ employee_record_code_3436.process(
employee_record_code_3436.asp_processing_code,
employee_record_code_3436.asp_processing_label,
'{"codeTraitement": "3436"}',
@@ -559,7 +559,7 @@ def test_processed_as_duplicate(self):
assert employee_record_code_3436.archived_json == {"codeTraitement": "3436"}
with pytest.raises(ValueError, match="Code needs to be 3436 and not 3437 when as_duplicate=True"):
- employee_record_other_code.update_as_processed(
+ employee_record_other_code.process(
employee_record_other_code.asp_processing_code,
employee_record_other_code.asp_processing_label,
None,
@@ -567,7 +567,7 @@ def test_processed_as_duplicate(self):
)
with pytest.raises(xworkflows.InvalidTransitionError):
- employee_record_other_status.update_as_processed(
+ employee_record_other_status.process(
employee_record_other_status.asp_processing_code,
employee_record_other_status.asp_processing_label,
None,
@@ -591,7 +591,7 @@ def setUp(self, _mock):
self.job_application = JobApplicationWithCompleteJobSeekerProfileFactory(hiring_start_at=hiring_date)
self.employee_record = EmployeeRecord.from_job_application(self.job_application)
- self.employee_record.update_as_ready()
+ self.employee_record.ready()
class TestEmployeeRecordQueryset:
diff --git a/tests/www/employee_record_views/test_disable.py b/tests/www/employee_record_views/test_disable.py
index d320c14171..9453060138 100644
--- a/tests/www/employee_record_views/test_disable.py
+++ b/tests/www/employee_record_views/test_disable.py
@@ -40,7 +40,7 @@ def test_disable_employee_record_new(self, client):
assert self.employee_record.status == Status.DISABLED
def test_disable_employee_record_ready(self, client):
- self.employee_record.update_as_ready()
+ self.employee_record.ready()
self.employee_record.refresh_from_db()
assert self.employee_record.status == Status.READY
@@ -54,8 +54,8 @@ def test_disable_employee_record_ready(self, client):
assert self.employee_record.status == Status.READY
def test_disable_employee_record_sent(self, client, faker):
- self.employee_record.update_as_ready()
- self.employee_record.update_as_sent(faker.asp_batch_filename(), 1, None)
+ self.employee_record.ready()
+ self.employee_record.sent(faker.asp_batch_filename(), 1, None)
self.employee_record.refresh_from_db()
assert self.employee_record.status == Status.SENT
@@ -69,10 +69,10 @@ def test_disable_employee_record_sent(self, client, faker):
assert self.employee_record.status == Status.SENT
def test_disable_employee_record_rejected(self, client, faker):
- self.employee_record.update_as_ready()
- self.employee_record.update_as_sent(faker.asp_batch_filename(), 1, None)
+ self.employee_record.ready()
+ self.employee_record.sent(faker.asp_batch_filename(), 1, None)
err_code, err_message = "12", "JSON Invalide"
- self.employee_record.update_as_rejected(err_code, err_message, None)
+ self.employee_record.reject(err_code, err_message, None)
self.employee_record.refresh_from_db()
assert self.employee_record.status == Status.REJECTED
@@ -88,10 +88,10 @@ def test_disable_employee_record_rejected(self, client, faker):
assert self.employee_record.status == Status.DISABLED
def test_disable_employee_record_completed(self, client, faker):
- self.employee_record.update_as_ready()
- self.employee_record.update_as_sent(faker.asp_batch_filename(), 1, None)
+ self.employee_record.ready()
+ self.employee_record.sent(faker.asp_batch_filename(), 1, None)
process_code, process_message = "0000", "La ligne de la fiche salarié a été enregistrée avec succès."
- self.employee_record.update_as_processed(process_code, process_message, "{}")
+ self.employee_record.process(process_code, process_message, "{}")
self.employee_record.refresh_from_db()
assert self.employee_record.status == Status.PROCESSED
diff --git a/tests/www/employee_record_views/test_list.py b/tests/www/employee_record_views/test_list.py
index 61c5d7db82..a714431fc9 100644
--- a/tests/www/employee_record_views/test_list.py
+++ b/tests/www/employee_record_views/test_list.py
@@ -66,7 +66,7 @@ def test_new_employee_records_list(self, client):
job_application__job_seeker__last_name="Aaaaa",
job_application__hiring_start_at=timezone.localdate() - relativedelta(days=15),
)
- record.update_as_ready()
+ record.ready()
client.force_login(self.user)
url = f"{self.URL}?status=READY"
response = client.get(url)
@@ -251,9 +251,9 @@ def test_rejected_without_custom_message(self, client, faker):
client.force_login(self.user)
record = employee_record_factories.EmployeeRecordWithProfileFactory(job_application__to_company=self.company)
- record.update_as_ready()
- record.update_as_sent(faker.asp_batch_filename(), 1, None)
- record.update_as_rejected("0012", "JSON Invalide", None)
+ record.ready()
+ record.sent(faker.asp_batch_filename(), 1, None)
+ record.reject("0012", "JSON Invalide", None)
response = client.get(self.URL, data={"status": Status.REJECTED})
assertContains(response, "Erreur 0012")
@@ -292,7 +292,7 @@ def test_rejected_custom_messages(self, client, subtests):
for err_code, err_message, custom_err_message in tests_specs:
with subtests.test(err_code):
record.status = Status.SENT
- record.update_as_rejected(err_code, err_message, "{}")
+ record.reject(err_code, err_message, "{}")
response = client.get(self.URL, data={"status": Status.REJECTED})
assertContains(response, f"Erreur {err_code}")
@@ -366,9 +366,9 @@ def test_rejected_employee_records_sorted(self, client, snapshot):
job_application__hiring_start_at=timezone.localdate() - relativedelta(days=10),
)
for i, record in enumerate((recordA, recordZ)):
- record.update_as_ready()
- record.update_as_sent(f"RIAE_FS_2021041013000{i}.json", 1, None)
- record.update_as_rejected("0012", "JSON Invalide", None)
+ record.ready()
+ record.sent(f"RIAE_FS_2021041013000{i}.json", 1, None)
+ record.reject("0012", "JSON Invalide", None)
# Zzzzz's hiring start is more recent
self._check_employee_record_order(
@@ -417,7 +417,7 @@ def test_ready_employee_records_sorted(self, client, snapshot):
job_application__hiring_start_at=timezone.localdate() - relativedelta(days=10),
)
for record in (recordA, recordZ):
- record.update_as_ready()
+ record.ready()
# Zzzzz's hiring start is more recent
self._check_employee_record_order(
diff --git a/tests/www/employee_record_views/test_reactivate.py b/tests/www/employee_record_views/test_reactivate.py
index fc28a1910e..6f56aa026d 100644
--- a/tests/www/employee_record_views/test_reactivate.py
+++ b/tests/www/employee_record_views/test_reactivate.py
@@ -22,11 +22,11 @@ def setup_method(self):
self.url = reverse("employee_record_views:reactivate", args=(self.employee_record.id,))
def test_reactivate_employee_record(self, client, faker):
- self.employee_record.update_as_ready()
- self.employee_record.update_as_sent(faker.asp_batch_filename(), 1, None)
+ self.employee_record.ready()
+ self.employee_record.sent(faker.asp_batch_filename(), 1, None)
process_code, process_message = "0000", "La ligne de la fiche salarié a été enregistrée avec succès."
- self.employee_record.update_as_processed(process_code, process_message, "{}")
- self.employee_record.update_as_disabled()
+ self.employee_record.process(process_code, process_message, "{}")
+ self.employee_record.disable()
client.force_login(self.user)
response = client.get(f"{self.url}?status=DISABLED")
diff --git a/tests/www/employee_record_views/test_summary.py b/tests/www/employee_record_views/test_summary.py
index ac91aae1f6..3aeb754010 100644
--- a/tests/www/employee_record_views/test_summary.py
+++ b/tests/www/employee_record_views/test_summary.py
@@ -39,8 +39,8 @@ def test_asp_batch_file_infos(self, client):
response = client.get(self.url)
assertNotContains(response, HORODATAGE)
- self.employee_record.update_as_ready()
- self.employee_record.update_as_sent("RIAE_FS_20210410130000.json", 1, None)
+ self.employee_record.ready()
+ self.employee_record.sent("RIAE_FS_20210410130000.json", 1, None)
response = client.get(self.url)
assertContains(response, HORODATAGE)