diff --git a/backend/condition/parsing/factory.py b/backend/condition/parsing/factory.py new file mode 100644 index 00000000..55b46253 --- /dev/null +++ b/backend/condition/parsing/factory.py @@ -0,0 +1,4 @@ +from backend.condition.parsing.parser import Parser + +def select_parser(filepath: str) -> Parser: + raise NotImplementedError \ No newline at end of file diff --git a/backend/condition/parsing/lbwf_parser.py b/backend/condition/parsing/lbwf_parser.py new file mode 100644 index 00000000..b0c233d3 --- /dev/null +++ b/backend/condition/parsing/lbwf_parser.py @@ -0,0 +1,8 @@ +from typing import BinaryIO, Any + +from backend.condition.parsing.parser import Parser + +class LbwfParser(Parser): + + def parse(self, file_stream: BinaryIO) -> Any: + raise NotImplementedError \ No newline at end of file diff --git a/backend/condition/parsing/parser.py b/backend/condition/parsing/parser.py new file mode 100644 index 00000000..105fda36 --- /dev/null +++ b/backend/condition/parsing/parser.py @@ -0,0 +1,8 @@ +from abc import ABC, abstractmethod +from typing import BinaryIO, Any + +class Parser(ABC): + + @abstractmethod + def parse(self, file_stream: BinaryIO) -> Any: + pass \ No newline at end of file diff --git a/backend/condition/processor.py b/backend/condition/processor.py index 1653f310..82f1b92e 100644 --- a/backend/condition/processor.py +++ b/backend/condition/processor.py @@ -3,4 +3,10 @@ from typing import BinaryIO, List from utils.logger import setup_logger def process_file(file_stream: BinaryIO, source_key: str) -> None: - print(f"[processor] Received file: {source_key}") \ No newline at end of file + print(f"[processor] Received file: {source_key}") + + # Instantiation + + + # Orchestration + diff --git a/backend/condition/tests/parsing/test_parsing_factory.py b/backend/condition/tests/parsing/test_parsing_factory.py new file mode 100644 index 00000000..dc2949f0 --- /dev/null +++ b/backend/condition/tests/parsing/test_parsing_factory.py @@ -0,0 +1,12 @@ +from backend.condition.parsing.factory import select_parser + +def test_selects_lbwf_parser(): + # arrange + file_path_str = "uploads/lbwf/Example Asset Data.xlsx" + expected_class_name = "LbwfParser" + + # act + actual_class_name = select_parser(file_path_str).__class__.__name__ + + # assert + assert expected_class_name == actual_class_name \ No newline at end of file diff --git a/pytest.ini b/pytest.ini index 84c686b1..1422657b 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,4 +1,4 @@ [pytest] pythonpath = . addopts = --cov-report term-missing --cov=etl/epc --cov=recommendations --cov=backend --cov=etl/epc_clean --cov=etl/spatial -testpaths = recommendations/tests backend/tests etl/epc/tests etl/epc_clean/tests etl/spatial/tests +testpaths = recommendations/tests backend/tests etl/epc/tests etl/epc_clean/tests etl/spatial/tests backend/condition/tests