-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_trails_time.py
More file actions
73 lines (59 loc) · 2.24 KB
/
test_trails_time.py
File metadata and controls
73 lines (59 loc) · 2.24 KB
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
63
64
65
66
67
68
69
70
71
72
73
"""Tests for trails time.py."""
import pandas as pd
from graphomotor.core import models
from graphomotor.features.trails import time
def test_total_error_time_no_errors() -> None:
"""Test case with no errors."""
df = pd.DataFrame(
{
"error": ["E0", "E0", "E0", "E0"],
"seconds": [0, 1, 2, 3],
}
)
drawing = models.Drawing(data=df, task_name="trails", metadata={"id": "5555555"})
result = time.calculate_total_error_time(drawing)
assert result == {"total_error_time": 0.0}
def test_single_error_chunk() -> None:
"""Test case with a single error chunk."""
df = pd.DataFrame(
{
"error": ["E0", "E1", "E1", "E0", "E0"],
"seconds": [0.0, 1.0, 3.0, 5.0, 6.0],
}
)
drawing = models.Drawing(data=df, task_name="trails", metadata={"id": "5555555"})
result = time.calculate_total_error_time(drawing)
assert result == {"total_error_time": 3.5}
def test_multiple_error_chunks() -> None:
"""Test case with multiple error chunks."""
df = pd.DataFrame(
{
"error": ["E0", "E1", "E1", "E0", "E2", "E2", "E0"],
"seconds": [0, 1, 3, 5, 6, 7, 9],
}
)
drawing = models.Drawing(data=df, task_name="trails", metadata={"id": "5555555"})
result = time.calculate_total_error_time(drawing)
assert result == {"total_error_time": 6.0}
def test_error_at_end() -> None:
"""Test case with an error chunk that goes to the end of the drawing."""
df = pd.DataFrame(
{
"error": ["E0", "E0", "E2", "E2"],
"seconds": [0.0, 1.0, 2.0, 4.0],
}
)
drawing = models.Drawing(data=df, task_name="trails", metadata={"id": "5555555"})
result = time.calculate_total_error_time(drawing)
assert result == {"total_error_time": 2.5}
def test_error_at_start() -> None:
"""Test case with an error chunk that starts at the beginning of the drawing."""
df = pd.DataFrame(
{
"error": ["E1", "E1", "E0", "E0"],
"seconds": [0.0, 1.0, 3.0, 4.0],
}
)
drawing = models.Drawing(data=df, task_name="trails", metadata={"id": "5555555"})
result = time.calculate_total_error_time(drawing)
assert result == {"total_error_time": 2.0}