Skip to content

Commit aebe27f

Browse files
authored
fix: update tests for recipes folder + minimal documentation (#4)
1 parent e0857ac commit aebe27f

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,11 @@ DataPytheon/
4545
├── tests/ # Basic unit tests for scripts
4646
│ └── test_titanic.py
4747
```
48+
49+
## 🧪 Run your tests
50+
51+
Just run the next command from the root folder of the project:
52+
53+
```
54+
pytest --cov=src
55+
```

tests/recipes/test_titanic.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,26 @@ def test_load_titanic_data_returns_dataframe():
1414
"survived",
1515
"pclass",
1616
"sex",
17-
"age",
1817
"sibsp",
1918
"parch",
2019
"fare",
2120
"embarked",
21+
"class",
22+
"who",
23+
"adult_male",
24+
"alone"
2225
}
26+
2327
missing_cols = expected_cols - set(df.columns)
28+
print(f"Missing columns: {missing_cols}")
2429
assert not missing_cols, f"Missing expected columns: {missing_cols}"
2530

26-
# Check no critical nulls remain in 'age' or 'embarked'
27-
assert df["age"].isnull().sum() == 0, "'age' column should have no nulls"
28-
assert df["embarked"].isnull().sum() == 0, "'embarked' column should have no nulls"
31+
# Check that 'embarked' column has more than one categorical values
32+
assert df["embarked"].nunique() > 1, "'embarked' column should have more than one unique value"
33+
34+
# Check that no null values exist in the DataFrame
35+
assert df.isnull().sum().sum() == 0, "DataFrame should not contain any null values"
2936

3037
# Check that some rows exist
3138
assert len(df) > 0, "DataFrame should not be empty"
39+

0 commit comments

Comments
 (0)