示例#1
0
def assert_load(data_to_load):
    mock_loader = mock.Mock()
    mock_loader.return_value = data_to_load
    ph = ProtonHelper(mock_loader)

    input_ = 'bacon'
    ph.load(input_)

    mock_loader.assert_called_once_with(input_)

    return ph
示例#2
0
def assert_load(data_to_load):
    mock_loader = mock.Mock()
    mock_loader.return_value = data_to_load
    ph = ProtonHelper(mock_loader)

    input_ = 'bacon'
    ph.load(input_)

    mock_loader.assert_called_once_with(input_)

    return ph
示例#3
0
def generate_output(file_reader, scorer):
    helper = ProtonHelper(yaml.load)

    # Load also validates the input as far as possible
    helper.load(file_reader.read())

    team_scoresheets = helper.team_scoresheets

    scores = None
    try:
        scores = scorer(team_scoresheets)
    except:
        print >> sys.stderr, traceback.format_exc()
        exit(2)

    assert scores is not None
    return helper.produce(scores)
示例#4
0
def generate_output(file_reader, scorer):
    helper = ProtonHelper(yaml.load)

    # Load also validates the input as far as possible
    helper.load(file_reader.read())

    team_scoresheets = helper.team_scoresheets

    scores = None
    try:
        scores = scorer(team_scoresheets)
    except:
        print >>sys.stderr, traceback.format_exc()
        exit(2)

    assert scores is not None
    return helper.produce(scores)
示例#5
0
def test_produce():
    input_ = {
        "match_number": 1,
        "teams": {
            "TLA1": {
                "zone": 0,
            },
            "TLA2": {
                "zone": 2,
                "present": False,
                "disqualified": True,
            },
        }
    }

    mock_loader = mock.Mock()
    mock_loader.return_value = input_
    ph = ProtonHelper(mock_loader)
    ph.load(None)

    scores = { "TLA1": 0, "TLA2": 13 }

    whole = ph.produce(scores)

    assert whole["version"] == "1.0.0"
    assert whole["match_number"] == 1
    assert whole["scores"] == {
        "TLA1": helpers.tla_result_fixture(0, 0),
        "TLA2": {
            "score": 13,
            "zone": 2,
        # while not sane these are expected to be pass-through
            "present": False,
            "disqualified": True,
        },
    }
示例#6
0
def test_produce():
    input_ = {
        "match_number": 1,
        "teams": {
            "TLA1": {
                "zone": 0,
            },
            "TLA2": {
                "zone": 2,
                "present": False,
                "disqualified": True,
            },
        }
    }

    mock_loader = mock.Mock()
    mock_loader.return_value = input_
    ph = ProtonHelper(mock_loader)
    ph.load(None)

    scores = {"TLA1": 0, "TLA2": 13}

    whole = ph.produce(scores)

    assert whole["version"] == "1.0.0"
    assert whole["match_number"] == 1
    assert whole["scores"] == {
        "TLA1": helpers.tla_result_fixture(0, 0),
        "TLA2": {
            "score": 13,
            "zone": 2,
            # while not sane these are expected to be pass-through
            "present": False,
            "disqualified": True,
        },
    }