-
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.
add tests for statistics calculations
- Loading branch information
1 parent
1598ac6
commit 4e5c604
Showing
3 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
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
Empty file.
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from unittest.mock import MagicMock | ||
|
||
import pytest | ||
|
||
from services.process_data import ProcessDataService | ||
|
||
|
||
class TestProcessData(object): | ||
@pytest.mark.parametrize( | ||
"durations,expected", | ||
[ | ||
( | ||
[], | ||
dict( | ||
mean_duration=None, | ||
median_duration=None, | ||
stdev_duration=None, | ||
p90_duration=None, | ||
), | ||
), | ||
( | ||
[1], | ||
dict( | ||
mean_duration=1, | ||
median_duration=1, | ||
stdev_duration=None, | ||
p90_duration=None, | ||
), | ||
), | ||
( | ||
[2, 2], | ||
dict( | ||
mean_duration=2, | ||
median_duration=2, | ||
stdev_duration=0, | ||
p90_duration=2, | ||
), | ||
), | ||
( | ||
[2, 3, 4, 5], | ||
dict( | ||
mean_duration=3.5, | ||
median_duration=3.5, | ||
stdev_duration=1.118033988749895, | ||
p90_duration=4.7, | ||
), | ||
), | ||
], | ||
) | ||
def test_calculate_statistics(self, durations, expected): | ||
process_data = ProcessDataService(MagicMock()) | ||
assert process_data.calculate_statistics(durations) == expected |