-
Notifications
You must be signed in to change notification settings - Fork 46
/
test_game.py
41 lines (34 loc) · 1.01 KB
/
test_game.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from unittest import TestCase
from game import Game
from game import User
class TestGame(TestCase):
def test_not_master(self):
game = Game()
game.start()
game.set_master(1)
word = game.get_word(2)
self.assertEqual('', word)
def test_master(self):
game = Game()
game.start()
game.set_master(1)
word = game.get_word(1)
self.assertEqual(game._current_word, word)
def test_answered(self):
game = Game()
game.start()
game.set_master(1)
is_answered = game.is_word_answered(2, game._current_word)
self.assertTrue(is_answered)
def test_not_answered(self):
game = Game()
game.start()
game.set_master(1)
is_answered = game.is_word_answered(2, " ")
self.assertFalse(is_answered)
def test_adding_rating(self):
game = Game()
game.start()
user = User(1, 'a')
user.update_rating()
self.assertEqual(1, user.get_rating())