39 lines
1.2 KiB
Python
39 lines
1.2 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_GetAPIv1ChartsPlayerAccuracyMap(BaseQ3StatsWebAppTestCase):
|
|
def test_ok(self):
|
|
fake_data = [
|
|
['Q3DM7', 'Q3DM17'],
|
|
[
|
|
{
|
|
'data': [1.23, 4.56],
|
|
'name': 'Rocket Launcher'
|
|
}
|
|
]
|
|
]
|
|
with mock.patch.object(views_mod.charts,
|
|
'get_player_avg_accuracy_chart',
|
|
return_value=fake_data):
|
|
with self.app.test_request_context():
|
|
rsp = self.client.get(
|
|
'/api/v1/charts/player/tomekwojcik/accuracy/map'
|
|
)
|
|
|
|
assert rsp.status_code == 200
|
|
|
|
views_mod.charts.get_player_avg_accuracy_chart.\
|
|
assert_called_with(
|
|
mock.ANY, 'tomekwojcik', agg_by='map'
|
|
)
|
|
|
|
assert rsp.json['maps'] == fake_data[0]
|
|
assert rsp.json['series'] == fake_data[1]
|