You've already forked q3stats
Q3Stats is now open source! :)
This commit is contained in:
122
tests_lib/test_lib_charts_day.py
Normal file
122
tests_lib/test_lib_charts_day.py
Normal file
@@ -0,0 +1,122 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import datetime
|
||||
import mock
|
||||
|
||||
from q3stats.lib.charts import day
|
||||
from q3stats.lib.scripts import utils
|
||||
from q3stats.models import Game, Score
|
||||
from q3stats.testing import BaseQ3StatsTestCase
|
||||
|
||||
|
||||
class Test_LibChartsDay(BaseQ3StatsTestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(Test_LibChartsDay, cls).setUpClass()
|
||||
|
||||
with utils.db_session(cls._config) as session:
|
||||
game1_dt = datetime.datetime(2017, 2, 14, 20, 21, 0)
|
||||
|
||||
game1 = Game(
|
||||
uuid='game1',
|
||||
map='Q3DM7',
|
||||
date=game1_dt.date(),
|
||||
time=game1_dt.time(),
|
||||
fraglimit=20,
|
||||
attrs={}
|
||||
)
|
||||
|
||||
game1.scores.extend([
|
||||
Score(
|
||||
player='Player 1',
|
||||
score=20,
|
||||
kills=21,
|
||||
deaths=10,
|
||||
suicides=1,
|
||||
net=11,
|
||||
damage_taken=123,
|
||||
damage_given=456,
|
||||
total_health=123,
|
||||
total_armor=456,
|
||||
weapons={},
|
||||
items={},
|
||||
powerups={}
|
||||
),
|
||||
Score(
|
||||
player='Player 2',
|
||||
score=10,
|
||||
kills=11,
|
||||
deaths=20,
|
||||
suicides=1,
|
||||
net=10,
|
||||
damage_taken=123,
|
||||
damage_given=456,
|
||||
total_health=123,
|
||||
total_armor=456,
|
||||
weapons={},
|
||||
items={},
|
||||
powerups={}
|
||||
),
|
||||
])
|
||||
|
||||
game2_dt = game1_dt + datetime.timedelta(seconds=60)
|
||||
game2 = Game(
|
||||
uuid='game2',
|
||||
map='Q3DM17',
|
||||
date=game2_dt.date(),
|
||||
time=game2_dt.time(),
|
||||
fraglimit=20,
|
||||
attrs={}
|
||||
)
|
||||
|
||||
game2.scores.extend([
|
||||
Score(
|
||||
player='Player 1',
|
||||
score=10,
|
||||
kills=11,
|
||||
deaths=20,
|
||||
suicides=1,
|
||||
net=10,
|
||||
damage_taken=123,
|
||||
damage_given=456,
|
||||
total_health=123,
|
||||
total_armor=456,
|
||||
weapons={},
|
||||
items={},
|
||||
powerups={}
|
||||
),
|
||||
Score(
|
||||
player='Player 2',
|
||||
score=20,
|
||||
kills=21,
|
||||
deaths=10,
|
||||
suicides=1,
|
||||
net=11,
|
||||
damage_taken=123,
|
||||
damage_given=456,
|
||||
total_health=123,
|
||||
total_armor=456,
|
||||
weapons={},
|
||||
items={},
|
||||
powerups={}
|
||||
),
|
||||
])
|
||||
|
||||
session.add_all([game1, game2])
|
||||
session.commit()
|
||||
|
||||
cls._day = game1_dt.date()
|
||||
|
||||
def test_get_day_chart(self):
|
||||
with utils.db_session(self._config) as session:
|
||||
maps, scores = day.get_day_chart(self._day, session)
|
||||
|
||||
assert maps == ['Q3DM7', 'Q3DM17']
|
||||
|
||||
pl1_scores, pl2_scores = scores
|
||||
|
||||
assert pl1_scores['name'] == 'Player 1'
|
||||
assert pl1_scores['data'] == [20, 10]
|
||||
|
||||
assert pl2_scores['name'] == 'Player 2'
|
||||
assert pl2_scores['data'] == [10, 20]
|
||||
Reference in New Issue
Block a user