Skip to content

Commit 4d9923f

Browse files
feat: added testing workflow and tests for extract.py
1 parent 6e5d072 commit 4d9923f

File tree

14 files changed

+59
-6
lines changed

14 files changed

+59
-6
lines changed

.gitignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
node_modules
1+
node_modules
2+
# Ignore virtual environments
3+
myenv/
4+
venv/
5+
.env
6+
.venv
7+
ENV/
8+
env.bak/
9+
venv.bak/

app/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# i just created this file so python know this directory is package and can import from it (needed to import extract function in root/tests/test_extract.py)
129 Bytes
Binary file not shown.

app/etl/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# i just created this file so python know this directory is package and can import from it (needed to import extract function in root/tests/test_extract.py)
133 Bytes
Binary file not shown.
1.53 KB
Binary file not shown.

app/etl/extract.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def extract(path: str = "xyz.csv") -> pd.DataFrame :
2121
if not os.path.exists(path):
2222
raise FileNotFoundError(f"❌ File not found: {path}")
2323

24-
if not path.lower().endswith('.csv'): # TODO (Find & Fix)
24+
if not str(path).lower().endswith('.csv'):
2525
raise ValueError(f"❌ File must be a CSV: {path}")
2626

2727
try:
@@ -32,12 +32,12 @@ def extract(path: str = "xyz.csv") -> pd.DataFrame :
3232
for encoding in encodings:
3333
try:
3434
# TODO (Find & Fix)
35-
pass
35+
pass
3636
except UnicodeDecodeError:
3737
print(f"Failed to read with encoding '{encoding}'") # Log the encoding that failed
3838

3939
if df is None:
40-
raise ValueError(f" Could not read CSV with tried encodings: {encodings}")
40+
raise ValueError(f"Could not read CSV with tried encodings: {encodings}")
4141

4242
# Validate data
4343
if df.empty:
@@ -50,5 +50,3 @@ def extract(path: str = "xyz.csv") -> pd.DataFrame :
5050
raise ValueError("❌ File contains no data")
5151
except pd.errors.ParserError as e:
5252
raise ValueError(f"❌ Error parsing CSV: {e}")
53-
except Exception as e:
54-
raise ValueError(f"❌ Unexpected error reading file: {e}")

tests/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# i just created this file so python know this directory is package and can import from it (needed to import extract function in root/tests/test_extract.py)
131 Bytes
Binary file not shown.
2.32 KB
Binary file not shown.

0 commit comments

Comments
 (0)