test_models_score.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # -*- coding: utf-8 -*-
  2. from q3stats.models import Score
  3. class Test_GameModel(object):
  4. def test_to_json(self):
  5. score = Score(
  6. id=1,
  7. game_id=1,
  8. player='Player 1',
  9. score=10,
  10. kills=20,
  11. deaths=30,
  12. suicides=40,
  13. net=50,
  14. damage_taken=123,
  15. damage_given=456,
  16. total_health=100,
  17. total_armor=200,
  18. weapons={
  19. 'G': {'hits': 1, 'shots': 0, 'kills': 1}
  20. },
  21. items={
  22. 'MH': 1
  23. },
  24. powerups={
  25. 'Quad': [5, 123456]
  26. }
  27. )
  28. result = score.to_json()
  29. assert result['id'] == score.id
  30. assert result['game_id'] == score.game_id
  31. assert result['player'] == score.player
  32. assert result['score'] == score.score
  33. assert result['kills'] == score.kills
  34. assert result['deaths'] == score.deaths
  35. assert result['suicides'] == score.suicides
  36. assert result['net'] == score.net
  37. assert result['damage_taken'] == score.damage_taken
  38. assert result['damage_given'] == score.damage_given
  39. assert result['total_health'] == score.total_health
  40. assert result['total_armor'] == score.total_armor
  41. assert result['weapons'] == score.weapons
  42. assert result['items'] == score.items
  43. assert result['powerups'] == score.powerups