-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_utils.py
62 lines (42 loc) · 1.49 KB
/
test_utils.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import pytest
from utils import (
remove_non_integer_values,
load_data,
check_non_integer_values,
add_parameters,
)
def test_remove():
"""
Tests the remove_non_integer_values function.
This function tests the remove_non_integer_values function by loading the data, removing non-integer values, and checking that the number of columns is equal to the number of columns that contain only integer values.
Returns:
None.
"""
data = load_data("data/data.txt")
data = remove_non_integer_values(data)
integer_columns_length = 0
for column in data.columns:
non_integer_values = check_non_integer_values(data, column)
integer_columns_length += 1
assert len(non_integer_values) == 0
assert len(data.columns) == integer_columns_length
def test_add_parameters():
"""
Tests the add_parameters function.
This function tests the add_parameters function by loading the data, removing non-integer values, adding the new parameters, and checking that the new parameters are in the data frame.
Returns:
None.
"""
data = load_data("data/data.txt")
data = remove_non_integer_values(data)
added_parameters = [
"power_to_weight",
"acceleration_efficiency",
"displacement_per_cylinder",
"weight_per_cylinder",
]
data = add_parameters(data)
for parameter in added_parameters:
assert parameter in data.columns
if __name__ == "__main__":
pytest.main()