This repository has been archived by the owner on Nov 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: test Titanic example more thoroughly (#22)
Closes #16. ### Summary of Changes Now we also check * number of rows * schema * which columns have missing values. --------- Co-authored-by: lars-reimann <[email protected]>
- Loading branch information
1 parent
d8e8a1b
commit 54c568f
Showing
3 changed files
with
56 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 41 additions & 4 deletions
45
tests/safeds_examples/tabular/titanic/test_load_titanic.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,46 @@ | ||
import pytest | ||
from safeds.data.tabular import Table | ||
from safeds.data.tabular.typing import ( | ||
FloatColumnType, | ||
IntColumnType, | ||
StringColumnType, | ||
TableSchema, | ||
) | ||
from safeds_examples.tabular import load_titanic | ||
|
||
|
||
def test_load_titanic() -> None: | ||
titanic = load_titanic() | ||
class TestLoadTitanic: | ||
@pytest.fixture | ||
def titanic(self) -> Table: | ||
return load_titanic() | ||
|
||
assert isinstance(titanic, Table) | ||
assert titanic.count_rows() > 0 | ||
@pytest.mark.smoke | ||
def test_returns_table(self) -> None: | ||
titanic = load_titanic() | ||
|
||
assert isinstance(titanic, Table) | ||
|
||
def test_row_count(self, titanic: Table) -> None: | ||
assert titanic.count_rows() == 1309 | ||
|
||
def test_schema(self, titanic: Table) -> None: | ||
assert titanic.schema == TableSchema( | ||
{ | ||
"Age": FloatColumnType(), | ||
"Cabin Number": StringColumnType(), | ||
"Fare": FloatColumnType(), | ||
"Name": StringColumnType(), | ||
"Number of Parents or Children Aboard": IntColumnType(), | ||
"Number of Siblings or Spouses Aboard": IntColumnType(), | ||
"Port of Embarkation": StringColumnType(), | ||
"Sex": StringColumnType(), | ||
"Survived": IntColumnType(), | ||
"Ticket Number": StringColumnType(), | ||
"Travel Class": IntColumnType(), | ||
} | ||
) | ||
|
||
def test_columns_with_missing_values(self, titanic: Table) -> None: | ||
actual_column_names = {column.name for column in titanic.list_columns_with_missing_values()} | ||
|
||
assert actual_column_names == {"Age", "Port of Embarkation", "Fare", "Cabin Number"} |