Skip to content

Commit

Permalink
inplement unit testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-dillon committed Sep 5, 2023
1 parent b330d6e commit 1729297
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1729297

Please sign in to comment.