def create_game(): game = Game() game.home_team.points = MagicMock() game.home_team.set_points = MagicMock() game.away_team.points = MagicMock() game.away_team.set_points = MagicMock() game.match_clock = MagicMock() game.twenty_four_clock = MagicMock() game.period = MagicMock() return game
def test_game_to_dict(): game = Game() temp_dict = { 'home_name': "Foo", 'home_points': 0, 'home_set_points': 0, 'home_penalty': False, 'home_timeout': False, 'away_name': "Foo", 'away_points': 0, 'away_set_points': 0, 'away_penalty': False, 'away_timeout': False, 'match_seconds': 0, 'match_twenty_four_seconds': 0, 'match_period': 1 } assert game.to_dict() == temp_dict
from autobahn.twisted.websocket import WebSocketServerProtocol from twisted.internet.defer import Deferred from twisted.internet import task, reactor from virtual_score_board.models import Game, User from virtual_score_board.command_parser import Parser, ParseError from virtual_score_board.parser_types import ParserTypeError from virtual_score_board.parser_responses import CorrectCredentials, SignedOut, CannotParse,\ WrongDataType, UnknownError, NotJson import json game = Game() template_dict = { 'home_name': 'Foo', 'home_score': 0, 'home_penalty': False, 'home_timeout': False, 'away_name': 'Bar', 'away_score': 0, 'away_penalty': False, 'away_timeout': False, 'match_seconds': 350, 'match_period': 1 } class ServerHandler(WebSocketServerProtocol): second_deffer = None parser = Parser(game) def __init__(self):
def test_game_get_clock_what_in_fail(): game = Game() with pytest.raises(ClockKeyError) as excinfo: game.get_clock("duck") assert "Only 'match' or 'twenty_four' key is permitted" in str(excinfo.value)
def test_game_get_clock_in_case_twenty_four(): game = Game() assert game.get_clock("twenty_four") is game.twenty_four_clock
def test_game_get_clock_in_case_match(): game = Game() assert game.get_clock("match") is game.match_clock
def test_game_get_team_what_in_fail(): game = Game() with pytest.raises(TeamKeyError) as excinfo: game.get_team("cow") assert "Only 'home' or 'away' key is permitted" in str(excinfo.value)
def test_game_get_team_in_case_away(): game = Game() assert game.get_team("away") is game.away_team
def test_game_get_team_in_case_home(): game = Game() assert game.get_team("home") is game.home_team
def test_game_get_clock_what_in_fail(): game = Game() with pytest.raises(ClockKeyError) as excinfo: game.get_clock("duck") assert "Only 'match' or 'twenty_four' key is permitted" in str( excinfo.value)