Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .mise.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[tools]
python="3.11"
poetry="2.2"
poetry="2.2.1"
java="liberica-1.8.0"
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
python 3.11.14
poetry 2.2.0
poetry 2.2.1
java liberica-1.8.0
21 changes: 7 additions & 14 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ faker = "18.11.1"
behave = "1.3.3"
coverage = "7.11.0"
moto = {extras = ["s3"], version = "4.0.13"}
Werkzeug = "3.0.6" # Dependency of moto which needs 3.0.6 for security vuln mitigation
Werkzeug = "3.1.5"
pytest = "8.4.2"
pytest-lazy-fixtures = "1.4.0" # switched from https://github.com/TvoroG/pytest-lazy-fixture as it's no longer supported
xlsx2csv = "0.8.2"
Expand Down
11 changes: 2 additions & 9 deletions src/dve/core_engine/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os
import uuid
from collections.abc import MutableMapping
from pathlib import Path, PurePath
from pathlib import Path
from typing import Any, Optional

from pydantic import UUID4, BaseModel, Field, FilePath, root_validator, validator
Expand Down Expand Up @@ -64,16 +64,9 @@ class SubmissionInfo(AuditRecord):
datetime_received: Optional[dt.datetime] = None # type: ignore
"""The datetime the file was received."""

@validator("file_name")
def _ensure_metadata_extension_removed(cls, filename): # pylint: disable=no-self-argument
path = PurePath(filename)
return path.stem

@validator("file_extension")
def _ensure_just_file_stem(cls, extension: str): # pylint: disable=no-self-argument
if "." in extension:
return extension.split(".")[-1]
return extension
return extension.rsplit(".", 1)[-1]

@property
def file_name_with_ext(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/features/steps/steps_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def submit_file_for_processing(context: Context, dataset: str, file_name: str):
sub_info = {
"submission_id": uuid4().hex,
"dataset_id": dataset,
"file_name": file_name,
"file_name": file_name.rsplit(".", 1)[0],
"file_extension": Path(file_name).suffix,
"reporting_period_start": "2025-11-01 00:00:00",
"reporting_period_end": "2025-11-30 23:59:59"
Expand Down
44 changes: 39 additions & 5 deletions tests/test_core_engine/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"submitted": {
"submission_id": CONSTANT_SUBMISSION_ID,
"dataset_id": "test0",
"file_name": "my_file.csv",
"file_name": "my_file",
"file_extension": "csv",
},
"expected": {
Expand All @@ -35,13 +35,13 @@
"submitted": {
"submission_id": CONSTANT_SUBMISSION_ID,
"dataset_id": "test1",
"file_name": "my_file.csv.csv",
"file_extension": "csv",
"file_name": "my_file",
"file_extension": ".csv.csv",
},
"expected": {
"submission_id": CONSTANT_SUBMISSION_ID,
"dataset_id": "test1",
"file_name": "my_file.csv",
"file_name": "my_file",
"file_extension": "csv",
},
},
Expand All @@ -52,7 +52,7 @@
"submitted": {
"submission_id": CONSTANT_SUBMISSION_ID,
"dataset_id": "test2",
"file_name": "my_file.xml",
"file_name": "my_file",
"file_extension": "csv.csv.xml",
},
"expected": {
Expand All @@ -63,6 +63,40 @@
},
},
),
# submission with multiple file extensions
(
{
"submitted": {
"submission_id": CONSTANT_SUBMISSION_ID,
"dataset_id": "test2",
"file_name": "my.file.perfect",
"file_extension": "csv",
},
"expected": {
"submission_id": CONSTANT_SUBMISSION_ID,
"dataset_id": "test2",
"file_name": "my.file.perfect",
"file_extension": "csv",
},
},
),
# submission with multiple file extensions
(
{
"submitted": {
"submission_id": CONSTANT_SUBMISSION_ID,
"dataset_id": "test2",
"file_name": "m_y%fil\ne.perfect",
"file_extension": "csv",
},
"expected": {
"submission_id": CONSTANT_SUBMISSION_ID,
"dataset_id": "test2",
"file_name": "m_y%fil\ne.perfect",
"file_extension": "csv",
},
},
),
],
)
def test_submission_info( # pylint: disable=missing-function-docstring
Expand Down