From 1729297b21e085a4a839f8cc1bf66e1fa7065da7 Mon Sep 17 00:00:00 2001 From: jeff-dillon Date: Tue, 5 Sep 2023 11:51:23 -0400 Subject: [PATCH] inplement unit testing --- tests.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests.py diff --git a/tests.py b/tests.py new file mode 100644 index 0000000..b410b49 --- /dev/null +++ b/tests.py @@ -0,0 +1,29 @@ +import os +import pandas as pd +import pytest + +CSV_FILE = "data/fashion_magazines.csv" + +def test_file_exists(): + assert os.path.exists(CSV_FILE) == True, "csv file does not exist" + +def test_columns_exist(): + expected_columns = ['Customer','Amount Due'] + try: + df = pd.read_csv(CSV_FILE) + for col in expected_columns: + assert col in df.columns + except Exception as e: + assert False, e + +@pytest.mark.parametrize("expected_customer,expected_amount", + [["Bethann Schraub",102], + ["Eryn Vilar",102], + ["Janay Priolo",57], + ["Lizabeth Letsche",237]]) +def test_values_exist(expected_customer, expected_amount): + try: + df = pd.read_csv(CSV_FILE) + assert df.loc[df['Customer'] == expected_customer]['Amount Due'].iloc[0] == expected_amount + except Exception as e: + assert False, e \ No newline at end of file