Add test support for xlsx file (not tested)
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import unittest
|
import unittest
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
# from convert_to_sportspress
|
# from convert_to_sportspress
|
||||||
from src.utils.common import validate_csv_header, normalize_header_key, read_and_normalize_csv, parse_score, is_visitor_home_order_reversed, import_gamebygame, aggregate_teams
|
from src.utils.common import validate_csv_header, normalize_header_key, read_and_normalize_csv_or_xlsx, parse_score, is_visitor_home_order_reversed, import_gamebygame, aggregate_teams
|
||||||
from src.utils.normalize import normalize_value, normalize_header_key, load_config
|
from src.utils.normalize import normalize_value, normalize_header_key, load_config
|
||||||
import toml
|
import toml
|
||||||
|
|
||||||
@@ -25,11 +25,11 @@ class TestConvertToSportsPress(unittest.TestCase):
|
|||||||
def test_read_csv(self):
|
def test_read_csv(self):
|
||||||
# Assuming that the CSV file has a valid header
|
# Assuming that the CSV file has a valid header
|
||||||
with self.subTest("Read CSV data"):
|
with self.subTest("Read CSV data"):
|
||||||
data = read_and_normalize_csv(self.test_csv_path_2009)
|
data = read_and_normalize_csv_or_xlsx(self.test_csv_path_2009)
|
||||||
self.assertIsInstance(data, list)
|
self.assertIsInstance(data, list)
|
||||||
self.assertTrue(all(isinstance(row, dict) for row in data))
|
self.assertTrue(all(isinstance(row, dict) for row in data))
|
||||||
with self.subTest("Normalized keys"):
|
with self.subTest("Normalized keys"):
|
||||||
normalized_data = read_and_normalize_csv(self.test_csv_path_2009)
|
normalized_data = read_and_normalize_csv_or_xlsx(self.test_csv_path_2009)
|
||||||
self.assertTrue(all("visitor" in row.keys() and "results" in row.keys() for row in normalized_data))
|
self.assertTrue(all("visitor" in row.keys() and "results" in row.keys() for row in normalized_data))
|
||||||
|
|
||||||
def test_parse_score_visitor_first(self):
|
def test_parse_score_visitor_first(self):
|
||||||
@@ -117,7 +117,7 @@ class TestConvertToSportsPress(unittest.TestCase):
|
|||||||
|
|
||||||
def test_process_data(self):
|
def test_process_data(self):
|
||||||
# Assuming that the CSV file has a valid header and read_csv is good
|
# Assuming that the CSV file has a valid header and read_csv is good
|
||||||
data = read_and_normalize_csv(self.test_csv_path_2009)
|
data = read_and_normalize_csv_or_xlsx(self.test_csv_path_2009)
|
||||||
processed_data = import_gamebygame(data)
|
processed_data = import_gamebygame(data)
|
||||||
aggregate_team_data = aggregate_teams(processed_data)
|
aggregate_team_data = aggregate_teams(processed_data)
|
||||||
expected_result = [
|
expected_result = [
|
||||||
|
|||||||
Reference in New Issue
Block a user