test_get_api_v1_charts_player_accuracy_map.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # -*- coding: utf -*-
  2. import datetime
  3. import mock
  4. from q3stats.testing import BaseQ3StatsWebAppTestCase
  5. from q3stats.web_app.blueprints.api_v1.views import charts as views_mod
  6. class Test_GetAPIv1ChartsPlayerAccuracyMap(BaseQ3StatsWebAppTestCase):
  7. def test_ok(self):
  8. fake_data = [
  9. ['Q3DM7', 'Q3DM17'],
  10. [
  11. {
  12. 'data': [1.23, 4.56],
  13. 'name': 'Rocket Launcher'
  14. }
  15. ]
  16. ]
  17. with mock.patch.object(views_mod.charts,
  18. 'get_player_avg_accuracy_chart',
  19. return_value=fake_data):
  20. with self.app.test_request_context():
  21. rsp = self.client.get(
  22. '/api/v1/charts/player/tomekwojcik/accuracy/map'
  23. )
  24. assert rsp.status_code == 200
  25. views_mod.charts.get_player_avg_accuracy_chart.\
  26. assert_called_with(
  27. mock.ANY, 'tomekwojcik', agg_by='map'
  28. )
  29. assert rsp.json['maps'] == fake_data[0]
  30. assert rsp.json['series'] == fake_data[1]