-
Notifications
You must be signed in to change notification settings - Fork 62
/
tests.py
29 lines (25 loc) · 956 Bytes
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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.00"],
["Eryn Vilar","$102.00"],
["Janay Priolo","$57.00"],
["Lizabeth Letsche","$237.00"]])
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