87 lines
2.4 KiB
Python
87 lines
2.4 KiB
Python
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")
|
|
shutil.copyfile("tests/datas/reviewstats_empty.csv", "tests/reviews/reviewstats_empty.csv")
|
|
|
|
|
|
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
|
|
|
|
|
|
def test_reviewstats():
|
|
review = ReviewStats("tests/reviews/reviewstats_2.csv")
|
|
review.load()
|
|
assert review.size == 16
|
|
assert review.first is not None
|
|
assert review.biggest is not None
|
|
assert review.min_users == 1
|
|
assert review.max_users == 10
|
|
assert review.avg_users == 3.1875
|
|
assert review.min_duration == 3
|
|
assert review.max_duration == 17
|
|
assert review.avg_duration == 7.0
|
|
assert review.year_review(2012) == 2
|
|
|
|
|
|
def test_reviewstats_empty():
|
|
review = ReviewStats("tests/reviews/reviewstats_empty.csv")
|
|
review.load()
|
|
assert review.size == 0
|
|
assert review.first is None
|
|
assert review.biggest is None
|
|
assert review.min_users == 0
|
|
assert review.max_users == 0
|
|
assert review.avg_users == 0
|
|
assert review.min_duration == 0
|
|
assert review.max_duration == 0
|
|
assert review.avg_duration == 0
|
|
assert review.year_review(2012) == 0
|