test_get_api_v1_charts_player_wins_map.py 1.0 KB

123456789101112131415161718192021222324252627282930313233
  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_GetAPIv1ChartsPlayerWinsSession(BaseQ3StatsWebAppTestCase):
  7. def test_ok(self):
  8. fake_data = [
  9. ['Q3DM7', 'Q3DM17'],
  10. [3, 5],
  11. [2, 0]
  12. ]
  13. with mock.patch.object(views_mod.charts, 'get_player_wins_chart',
  14. return_value=fake_data):
  15. with self.app.test_request_context():
  16. rsp = self.client.get(
  17. '/api/v1/charts/player/tomekwojcik/wins/map'
  18. )
  19. assert rsp.status_code == 200
  20. views_mod.charts.get_player_wins_chart.assert_called_with(
  21. mock.ANY, 'tomekwojcik', agg_by='map'
  22. )
  23. assert rsp.json['maps'] == ['Q3DM7', 'Q3DM17']
  24. assert rsp.json['wins'] == [3, 5]
  25. assert rsp.json['losses'] == [2, 0]