test_lib_stats.py 926 B

123456789101112131415161718192021222324252627282930
  1. # -*- coding: utf-8 -*-
  2. from q3stats.lib import stats
  3. from q3stats.testing import BaseQ3StatsTestCase
  4. class Test_LibStats(BaseQ3StatsTestCase):
  5. def test_weapon_accuracy_gauntlet(self):
  6. result = stats.weapon_accuracy('G', {'hits': 0, 'shots': 0})
  7. assert result == '---'
  8. def test_weapon_accuracy_no_shots(self):
  9. result = stats.weapon_accuracy('BFG', {'hits': 1, 'shots': 0})
  10. assert result == 'NaN'
  11. def test_weapon_accuracy(self):
  12. result = stats.weapon_accuracy('BFG', {'hits': 1, 'shots': 2})
  13. assert result == '50.00%'
  14. def test_powerup_time_no_time(self):
  15. result = stats.powerup_time(0)
  16. assert result == 'NaN'
  17. def test_powerup_time_less_than_1s(self):
  18. result = stats.powerup_time(123)
  19. assert result == '0.123'
  20. def test_powerup_time(self):
  21. result = stats.powerup_time(12345)
  22. assert result == '12.345'