34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
# -*- coding: utf -*-
|
|
|
|
import datetime
|
|
|
|
import mock
|
|
|
|
from q3stats.testing import BaseQ3StatsWebAppTestCase
|
|
from q3stats.web_app.blueprints.api_v1.views import charts as views_mod
|
|
|
|
|
|
class Test_GetAPIv1ChartsPlayerWinsSession(BaseQ3StatsWebAppTestCase):
|
|
def test_ok(self):
|
|
fake_data = [
|
|
['Q3DM7', 'Q3DM17'],
|
|
[3, 5],
|
|
[2, 0]
|
|
]
|
|
with mock.patch.object(views_mod.charts, 'get_player_wins_chart',
|
|
return_value=fake_data):
|
|
with self.app.test_request_context():
|
|
rsp = self.client.get(
|
|
'/api/v1/charts/player/tomekwojcik/wins/map'
|
|
)
|
|
|
|
assert rsp.status_code == 200
|
|
|
|
views_mod.charts.get_player_wins_chart.assert_called_with(
|
|
mock.ANY, 'tomekwojcik', agg_by='map'
|
|
)
|
|
|
|
assert rsp.json['maps'] == ['Q3DM7', 'Q3DM17']
|
|
assert rsp.json['wins'] == [3, 5]
|
|
assert rsp.json['losses'] == [2, 0]
|