def test11(self): """ Check if __str__ function is available. If Game created (but not active) only cat information is printed If game is actived then cat and mouse position are given [X] vs [ ] report if it is the cat/mouse player turn. """ game = Game(id=0, cat_user=self.users[0]) self.assertEqual(str(game), "(0, Created)\tCat [X]" " cat_user_test(0, 2, 4, 6)") game.mouse_user = self.users[1] game.status = GameStatus.ACTIVE game.save() self.assertEqual( str(game), "(0, Active)\tCat [X] cat_user_test(0, 2, 4, 6)" " --- Mouse [ ] mouse_user_test(59)") game.cat_turn = False self.assertEqual( str(game), "(0, Active)\tCat [ ] " "cat_user_test(0, 2, 4, 6) --- Mouse [X] mouse_user_test(59)") game.status = GameStatus.FINISHED game.save() self.assertEqual( str(game), "(0, Finished)\tCat [ ]" " cat_user_test(0, 2, 4, 6) --- Mouse [X] mouse_user_test(59)" )
def test11(self): """ Conversiones a string """ game = Game(id=0, cat_user=self.users[0]) self.assertEqual(str(game), "(0, Created)\tCat [X] cat_user_test(0, 2, 4, 6)") game.mouse_user = self.users[1] game.status = GameStatus.ACTIVE game.save() self.assertEqual( str(game), "(0, Active)\tCat [X] cat_user_test(0, 2, 4, 6) --- Mouse [ ] mouse_user_test(59)" ) game.cat_turn = False self.assertEqual( str(game), "(0, Active)\tCat [ ] cat_user_test(0, 2, 4, 6) --- Mouse [X] mouse_user_test(59)" ) game.status = GameStatus.FINISHED game.save() self.assertEqual( str(game), "(0, Finished)\tCat [ ] cat_user_test(0, 2, 4, 6) --- Mouse [X] mouse_user_test(59)" )
def test1(self): """ Validación de la actualización del juego al ganar el raton""" game = Game(cat_user=self.user1) game.save() game.cat1 = 57 game.cat2 = 59 game.cat3 = 61 game.cat4 = 63 game.mouse = 18 game.mouse_user = self.user2 game.cat_turn = False game.save() move = Move(origin=18, target=11, player=self.user2, game=game) move.save() self.assertEqual(game.status, GameStatus.FINISHED)