Files
kukuc-clock/test/test_slovak_datetime_formatter.py
2023-12-21 23:14:09 +01:00

36 lines
1.1 KiB
Python

import unittest
from datetime import datetime
import csv
import imp
get_datetime_as_slovak_sentence = imp.load_source(
"slovak_datetime_formatter", "../lib/slovak_datetime_formatter.py"
).get_datetime_as_slovak_sentence
class TestSlovakDateTimeFormatter(unittest.TestCase):
def test(self):
test_data = []
with open("test_data.tsv") as file:
reader = csv.reader(file, delimiter="\t")
next(reader)
for row in reader:
if row and not row[0].startswith("#"):
test_data.append(row)
for time_str, date_str, expected_text in test_data:
test_datetime = datetime(
int(date_str.split("-")[2]),
int(date_str.split("-")[1]),
int(date_str.split("-")[0]),
int(time_str.split(":")[0]),
int(time_str.split(":")[1]),
)
output_text = get_datetime_as_slovak_sentence(test_datetime)
self.assertEqual(output_text, expected_text)
if __name__ == "__main__":
unittest.main()