Skip to content

Commit

Permalink
chore: change "pruned" to "talpa" for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
rikuke committed Dec 5, 2024
1 parent c1dd508 commit e44b8dd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 30 deletions.
5 changes: 2 additions & 3 deletions backend/benefit/applications/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def applications_csv_service_with_one_application(applications_csv_service):


@pytest.fixture
def pruned_applications_csv_service():
def talpa_applications_csv_service():
# retrieve the objects through the default manager so that annotations are added
application1 = DecidedApplicationFactory(application_number=100001)
application2 = DecidedApplicationFactory(application_number=100002)
Expand All @@ -194,8 +194,7 @@ def pruned_applications_csv_service():


@pytest.fixture
def pruned_applications_csv_service_with_one_application(
applications_csv_service, application_batch
def talpa_applications_csv_service_with_one_application(application_batch
):
application1 = application_batch.applications.all().first()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -603,14 +603,14 @@ def test_write_application_alterations_csv_file(
(True,),
],
)
def test_pruned_applications_csv_output(
pruned_applications_csv_service_with_one_application, instalments_enabled, settings
def test_talpa_applications_csv_output(
talpa_applications_csv_service_with_one_application, instalments_enabled, settings
):
settings.PAYMENT_INSTALMENTS_ENABLED = instalments_enabled

instalment_amount = decimal.Decimal("123.45")
application = (
pruned_applications_csv_service_with_one_application.get_applications()[0]
talpa_applications_csv_service_with_one_application.get_applications()[0]
)
if instalments_enabled:
application.calculation.instalments.all().delete()
Expand All @@ -624,7 +624,7 @@ def test_pruned_applications_csv_output(
)

csv_lines = split_lines_at_semicolon(
pruned_applications_csv_service_with_one_application.get_csv_string()
talpa_applications_csv_service_with_one_application.get_csv_string()
)
# Assert that there are 18 column headers in the pruned CSV
assert len(csv_lines[0]) == 18
Expand Down
46 changes: 23 additions & 23 deletions backend/benefit/applications/tests/test_talpa_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,59 +36,59 @@ def test_talpa_lines(applications_csv_service):
)


def test_talpa_csv_cell_list_lines_generator(pruned_applications_csv_service):
def test_talpa_csv_cell_list_lines_generator(talpa_applications_csv_service):
check_csv_cell_list_lines_generator(
pruned_applications_csv_service, expected_row_count_with_header=3
talpa_applications_csv_service, expected_row_count_with_header=3
)


def test_talpa_csv_string_lines_generator(pruned_applications_csv_service):
def test_talpa_csv_string_lines_generator(talpa_applications_csv_service):
check_csv_string_lines_generator(
pruned_applications_csv_service, expected_row_count_with_header=3
talpa_applications_csv_service, expected_row_count_with_header=3
)


def test_talpa_csv_output(pruned_applications_csv_service_with_one_application):
def test_talpa_csv_output(talpa_applications_csv_service_with_one_application):
csv_lines = split_lines_at_semicolon(
pruned_applications_csv_service_with_one_application.get_csv_string()
talpa_applications_csv_service_with_one_application.get_csv_string()
)
# BOM at the beginning of the file
assert csv_lines[0][0] == '\ufeff"Hakemusnumero"'
csv_columns = iter(pruned_applications_csv_service_with_one_application.CSV_COLUMNS)
csv_columns = iter(talpa_applications_csv_service_with_one_application.CSV_COLUMNS)
next(csv_columns, None) # Skip the first element

for idx, col in enumerate(csv_columns, start=1):
assert csv_lines[0][idx] == f'"{col.heading}"'

assert (
int(csv_lines[1][0])
== pruned_applications_csv_service_with_one_application.applications.first().application_number
== talpa_applications_csv_service_with_one_application.applications.first().application_number
)


def test_talpa_csv_non_ascii_characters(
pruned_applications_csv_service_with_one_application,
talpa_applications_csv_service_with_one_application,
):
application = (
pruned_applications_csv_service_with_one_application.applications.first()
talpa_applications_csv_service_with_one_application.applications.first()
)
application.company_name = "test äöÄÖtest"
application.save()
csv_lines = split_lines_at_semicolon(
pruned_applications_csv_service_with_one_application.get_csv_string()
talpa_applications_csv_service_with_one_application.get_csv_string()
)
assert csv_lines[1][3] == '"test äöÄÖtest"' # string is quoted


def test_talpa_csv_delimiter(pruned_applications_csv_service_with_one_application):
def test_talpa_csv_delimiter(talpa_applications_csv_service_with_one_application):
application = (
pruned_applications_csv_service_with_one_application.applications.first()
talpa_applications_csv_service_with_one_application.applications.first()
)
application.company_name = "test;12"
application.save()
assert (
';"test;12";'
in pruned_applications_csv_service_with_one_application.get_csv_string()
in talpa_applications_csv_service_with_one_application.get_csv_string()
)


Expand All @@ -100,13 +100,13 @@ def test_talpa_csv_delimiter(pruned_applications_csv_service_with_one_applicatio
],
)
def test_talpa_csv_decimal(
pruned_applications_csv_service_with_one_application,
talpa_applications_csv_service_with_one_application,
settings,
instalments_enabled,
):
settings.PAYMENT_INSTALMENTS_ENABLED = instalments_enabled
application = (
pruned_applications_csv_service_with_one_application.applications.first()
talpa_applications_csv_service_with_one_application.applications.first()
)
if instalments_enabled:
application.calculation.instalments.all().delete()
Expand All @@ -123,34 +123,34 @@ def test_talpa_csv_decimal(
application.calculation.save()

csv_lines = split_lines_at_semicolon(
pruned_applications_csv_service_with_one_application.get_csv_string()
talpa_applications_csv_service_with_one_application.get_csv_string()
)
assert csv_lines[1][8] == "123.45"


def test_talpa_csv_date(pruned_applications_csv_service_with_one_application):
def test_talpa_csv_date(talpa_applications_csv_service_with_one_application):
application = (
pruned_applications_csv_service_with_one_application.get_applications().first()
talpa_applications_csv_service_with_one_application.get_applications().first()
)
now = datetime.now(timezone.utc)
application.batch.decision_date = now
application.batch.save()
csv_lines = split_lines_at_semicolon(
pruned_applications_csv_service_with_one_application.get_csv_string()
talpa_applications_csv_service_with_one_application.get_csv_string()
)
assert csv_lines[1][12] == f'"{now.strftime("%Y-%m-%d")}"'


def test_write_talpa_csv_file(
pruned_applications_csv_service_with_one_application, tmp_path
talpa_applications_csv_service_with_one_application, tmp_path
):
application = (
pruned_applications_csv_service_with_one_application.applications.first()
talpa_applications_csv_service_with_one_application.applications.first()
)
application.company_name = "test äöÄÖtest"
application.save()
output_file = tmp_path / "output.csv"
pruned_applications_csv_service_with_one_application.write_csv_file(output_file)
talpa_applications_csv_service_with_one_application.write_csv_file(output_file)
with open(output_file, encoding="utf-8-sig") as f:
contents = f.read()
assert contents.startswith('"Hakemusnumero";"Työnantajan tyyppi"')
Expand Down

0 comments on commit e44b8dd

Please sign in to comment.