Newer
Older
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""
This test file tests the Dataset class in Dataset.py.
"""
from Dataset import Dataset
import pandas as pd
from pathlib import Path
import pytest
this_file_dir = Path(__file__).parent
@pytest.fixture
def the_dataset():
dataset = Dataset(this_file_dir / "../data/GamingStudy_data.csv")
return dataset
def test_load_Dataset_class():
dataset = Dataset(this_file_dir / "../data/GamingStudy_data.csv")
assert type(dataset) == Dataset
assert type(dataset.dataframe) == pd.DataFrame
def test_get_dataframe(the_dataset: Dataset):
assert type(the_dataset.get_dataframe()) == pd.DataFrame
def test_combined_anxiety_score(the_dataset: Dataset):
dataframe = the_dataset.get_dataframe()
anxiety_scores = the_dataset.get_combined_anxiety_score(dataframe)
assert anxiety_scores.dtype == float
assert anxiety_scores.min() >= 0
assert anxiety_scores.max() <= 1
def test_get_is_narcissist_col(the_dataset: Dataset):
dataframe = the_dataset.get_dataframe()
is_narcissist_row = the_dataset.get_is_narcissist_col(dataframe)
assert is_narcissist_row.dtype == bool
def test_preprocessed_dataframe(the_dataset: Dataset):
dataframe = the_dataset.get_dataframe()
columns_set = set(dataframe.columns)
assert "League" not in columns_set
assert "Anxiety_score" in columns_set
assert "Is_narcissist" in columns_set
def test_get_sorted_columns(the_dataset: Dataset):
sorted_GAD1 = the_dataset.get_sorted_column("GAD1")
assert sorted_GAD1.iloc[0] <= sorted_GAD1.iloc[-1]