コード例 #1
0
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
コード例 #2
0
ファイル: tests.py プロジェクト: SzateX/virtual_score_board
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
コード例 #3
0
ファイル: tests.py プロジェクト: SzateX/virtual_score_board
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
コード例 #4
0
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
コード例 #5
0
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):
コード例 #6
0
ファイル: tests.py プロジェクト: SzateX/virtual_score_board
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)
コード例 #7
0
ファイル: tests.py プロジェクト: SzateX/virtual_score_board
def test_game_get_clock_in_case_twenty_four():
    game = Game()
    assert game.get_clock("twenty_four") is game.twenty_four_clock
コード例 #8
0
ファイル: tests.py プロジェクト: SzateX/virtual_score_board
def test_game_get_clock_in_case_match():
    game = Game()
    assert game.get_clock("match") is game.match_clock
コード例 #9
0
ファイル: tests.py プロジェクト: SzateX/virtual_score_board
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)
コード例 #10
0
ファイル: tests.py プロジェクト: SzateX/virtual_score_board
def test_game_get_team_in_case_away():
    game = Game()
    assert game.get_team("away") is game.away_team
コード例 #11
0
ファイル: tests.py プロジェクト: SzateX/virtual_score_board
def test_game_get_team_in_case_home():
    game = Game()
    assert game.get_team("home") is game.home_team
コード例 #12
0
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)
コード例 #13
0
def test_game_get_clock_in_case_twenty_four():
    game = Game()
    assert game.get_clock("twenty_four") is game.twenty_four_clock
コード例 #14
0
def test_game_get_clock_in_case_match():
    game = Game()
    assert game.get_clock("match") is game.match_clock
コード例 #15
0
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)
コード例 #16
0
def test_game_get_team_in_case_away():
    game = Game()
    assert game.get_team("away") is game.away_team
コード例 #17
0
def test_game_get_team_in_case_home():
    game = Game()
    assert game.get_team("home") is game.home_team