generated from CLCK-Data-Aug2023/wine-reviews-2f2e75
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tests.py
33 lines (29 loc) · 1.12 KB
/
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
30
31
32
33
import os
import pandas as pd
import pytest
CSV_FILE = "data/reviews-per-country.csv"
def test_file_exists():
assert os.path.exists(CSV_FILE) == True, "csv file does not exist"
def test_columns_exist():
expected_columns = ['country','count','points']
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("country_name,expected_count,expected_points",
[['US', 54504, 88.6],
['France', 22093, 88.8],
['Italy', 19540, 88.6],
['Spain', 6645, 87.3],
['Israel', 505, 88.5],
['Egypt',1,84.0]
])
def test_values_exist(country_name, expected_count, expected_points):
try:
df = pd.read_csv(CSV_FILE)
assert df.loc[df['country'] == country_name]['count'].iloc[0] == expected_count
assert df.loc[df['country'] == country_name]['points'].iloc[0] == expected_points
except Exception as e:
assert False, e