Beispiel #1
0
def test_match_01(util_mock):
    """
    test_match use verify correctly
    Expected: 2 inovkations to verify
    """
    util.match('Scissors', 'Paper')

    expected_calls = [call('Scissors'), call('Paper')]
    util_mock.assert_has_calls(expected_calls)
Beispiel #2
0
def test_match_04(util_mock):
    """
    Input: p1=Paper p2=Rock \
    Expected: 1
    """
    result = util.match('Paper', 'Rock')

    util_mock.assert_called()
    ok_(result == 1, 'The result was ' + str(result))
Beispiel #3
0
def test_match_03(util_mock):
    """
    Input: p1=Rock p2=Scissors \
    Expected: 1
    """
    result = util.match('Rock', 'Scissors')

    util_mock.assert_called()
    ok_(result == 1, 'The result was ' + str(result))
Beispiel #4
0
def test_match_02(util_mock):
    """
    Input: p1=Scissors p2=Paper \
    Expected: 1
    """
    result = util.match('Scissors', 'Paper')

    util_mock.assert_called()
    ok_(result == 1, 'The result was ' + str(result))
Beispiel #5
0
def match(player):
    """
    Start a match vs a computer and return the output
    """
    computer = util.get_computer()
    match_output = util.match(player, computer)
    match_output_str = ''

    if match_output == 1:
        match_output_str = 'The player win'
    elif match_output == 2:
        match_output_str = 'The computer win'
    elif match_output == 0:
        match_output_str = 'It is a tie'
    else:
        return 'Server Error', 500

    return {
        'player': player,
        'computer': computer,
        'resutl_id': match_output,
        'result': match_output_str
    }