Ajout de tests pour les statistiques des revues

This commit is contained in:
Mindiell 2024-06-27 18:53:36 +02:00
parent 27df2d4d65
commit 65595039e1
3 changed files with 118 additions and 0 deletions

View File

@ -0,0 +1,16 @@
20110930-12h00 1
20111007-12h00 2
20111014-12h00 4
20111021-12h00 5
20111028-12h00 10
20111104-12h00 6
20111111-12h00 1
20111118-12h00 2
20111125-12h00 4
20111202-12h00 5
20111209-12h00 1
20111216-12h00 2
20111223-12h00 4
20111230-12h00 1
20120106-12h00 2
20120113-12h00 1
1 20110930-12h00 1
2 20111007-12h00 2
3 20111014-12h00 4
4 20111021-12h00 5
5 20111028-12h00 10
6 20111104-12h00 6
7 20111111-12h00 1
8 20111118-12h00 2
9 20111125-12h00 4
10 20111202-12h00 5
11 20111209-12h00 1
12 20111216-12h00 2
13 20111223-12h00 4
14 20111230-12h00 1
15 20120106-12h00 2
16 20120113-12h00 1

View File

@ -0,0 +1,16 @@
20110930-12h00 1
20111007-12h00 2
20111014-12h00 4
20111021-12h00 5
20111028-12h00 10
20111104-12h00 6
20111111-12h00 1
20111118-12h00 2
20111125-12h00 4
20111202-12h00 5 3
20111209-12h00 1 7
20111216-12h00 2 17
20111223-12h00 4 5
20111230-12h00 1 9
20120106-12h00 2 5
20120113-12h00 1 3
1 20110930-12h00 1
2 20111007-12h00 2
3 20111014-12h00 4
4 20111021-12h00 5
5 20111028-12h00 10
6 20111104-12h00 6
7 20111111-12h00 1
8 20111118-12h00 2
9 20111125-12h00 4
10 20111202-12h00 5 3
11 20111209-12h00 1 7
12 20111216-12h00 2 17
13 20111223-12h00 4 5
14 20111230-12h00 1 9
15 20120106-12h00 2 5
16 20120113-12h00 1 3

View File

@ -0,0 +1,86 @@
from datetime import datetime, timedelta
import re
import shutil
from review.stats import Board, UserBoard, DurationBoard, ReviewData, ReviewStats
def setup_function():
shutil.copyfile("tests/datas/reviewstats_1.csv", "tests/reviews/reviewstats_1.csv")
shutil.copyfile("tests/datas/reviewstats_2.csv", "tests/reviews/reviewstats_2.csv")
def load_reviewstats(filepath):
final_datas = []
try:
with open(filepath) as file_handle:
lines = file_handle.read().splitlines()
for line in lines:
if line.strip() != "":
datas = re.split(r"\s+", line)
if len(datas) == 2:
final_datas.append(
ReviewData(
datetime.strptime(datas[0], "%Y%m%d-%Hh%M"),
int(datas[1]),
None,
)
)
else:
final_datas.append(
ReviewData(
datetime.strptime(datas[0], "%Y%m%d-%Hh%M"),
int(datas[1]),
int(datas[2]),
)
)
except FileNotFoundError:
# no file, no stats
pass
return final_datas
def test_board():
board = Board()
assert board.datas == {}
assert board["test"] == 0
assert board.position("test") is None
assert board.min == 0
assert board.max == 0
assert board.avg == 0
assert board.sum == 0
def test_userboard():
review = ReviewStats("tests/reviews/reviewstats_1.csv")
review.load()
board = review.users_board
assert board["test"] == 0
assert board[1] == 5
assert board.min == 1
assert board.max == 10
assert board.sum == 51
assert board.avg == 3.1875
def test_durationboard():
review = ReviewStats("tests/reviews/reviewstats_1.csv")
review.load()
board = review.durations_board
assert board["test"] == 0
assert board.min == 0
assert board.max == 0
assert board.sum == 0
assert board.avg == 0
def test_durationboard():
review = ReviewStats("tests/reviews/reviewstats_2.csv")
review.load()
board = review.durations_board
assert board["test"] == 0
assert board.min == 3
assert board.max == 17
assert board.sum == 49
assert board.avg == 7.0