aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--cli.py4
-rw-r--r--obfuscator/csv_reader.py14
-rw-r--r--pyproject.toml1
-rw-r--r--test/test_csv_reader.py5
5 files changed, 17 insertions, 10 deletions
diff --git a/.gitignore b/.gitignore
index 78eaef5..42385eb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -172,3 +172,6 @@ cython_debug/
# Private notes
*.private
+
+# CSV Files
+*.csv
diff --git a/cli.py b/cli.py
index 652830e..19e64d8 100644
--- a/cli.py
+++ b/cli.py
@@ -15,8 +15,8 @@ def main():
if args.local and not args.s3:
logger.debug("User chose to read CSV from local path")
- reader = CSVReader(args.local)
- data = reader.read_local()
+ reader = CSVReader()
+ data = reader.read_local(args.local)
print(data)
else:
logger.debug("User chose to read CSV from S3")
diff --git a/obfuscator/csv_reader.py b/obfuscator/csv_reader.py
index 5bc91dc..cbd18c1 100644
--- a/obfuscator/csv_reader.py
+++ b/obfuscator/csv_reader.py
@@ -1,25 +1,25 @@
import csv
from typing import List, Dict
-from logger import get_logger
+from obfuscator.logger import get_logger
logger = get_logger("CSVReader")
class CSVReader:
- def __init__(self, path: str):
- self.path = path
+ def __init__(self):
+ pass
- def read_local(self) -> List[Dict[str, str]]:
- logger.debug(f"Reading local CSV from: {self.path}")
+ def read_local(self, path) -> List[Dict[str, str]]:
+ logger.debug(f"Reading local CSV from: {path}")
data = []
try:
- with open(self.path, mode="r", encoding="utf-8") as file:
+ with open(path, mode="r", encoding="utf-8") as file:
reader = csv.DictReader(file)
for row in reader:
data.append(dict(row))
except FileNotFoundError:
- logger.error(f"File not found: {self.path}")
+ logger.error(f"File not found: {path}")
except Exception as e:
logger.error(f"Error reading file: {e}")
diff --git a/pyproject.toml b/pyproject.toml
index a9cd511..d5db843 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -18,6 +18,7 @@ packages = [
[tool.poetry.group.dev.dependencies]
pytest = "8.3.4"
+pytest-cov = "^6.0.0"
[build-system]
requires = ["poetry-core>=2.0.0,<3.0.0"]
diff --git a/test/test_csv_reader.py b/test/test_csv_reader.py
index ac43b04..fb5996d 100644
--- a/test/test_csv_reader.py
+++ b/test/test_csv_reader.py
@@ -1,9 +1,12 @@
# csv_reader.py - tests
# Author: Alex Schofield
-from main import csv_reader
+from obfuscator.csv_reader import CSVReader
import pytest
+reader = CSVReader()
+
+### TODO : TESTS ARE BROKEN, FIX THEM IN NEXT BRANCH ###
def test_empty_csv_should_return_no_content():
content = ""
git.ajschof.me — hosted by ajschofield — powered by cgit