Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,11 @@ DataPytheon/
├── tests/ # Basic unit tests for scripts
│ └── test_titanic.py
```

## 🧪 Run your tests

Just run the next command from the root folder of the project:

```
pytest --cov=src
```
16 changes: 12 additions & 4 deletions tests/recipes/test_titanic.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,26 @@ def test_load_titanic_data_returns_dataframe():
"survived",
"pclass",
"sex",
"age",
"sibsp",
"parch",
"fare",
"embarked",
"class",
"who",
"adult_male",
"alone"
}

missing_cols = expected_cols - set(df.columns)
print(f"Missing columns: {missing_cols}")
assert not missing_cols, f"Missing expected columns: {missing_cols}"

# Check no critical nulls remain in 'age' or 'embarked'
assert df["age"].isnull().sum() == 0, "'age' column should have no nulls"
assert df["embarked"].isnull().sum() == 0, "'embarked' column should have no nulls"
# Check that 'embarked' column has more than one categorical values
assert df["embarked"].nunique() > 1, "'embarked' column should have more than one unique value"

# Check that no null values exist in the DataFrame
assert df.isnull().sum().sum() == 0, "DataFrame should not contain any null values"

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