Example #1
0
def test_concisecontract_call_default():
    mock = Mock()
    sweet_method = ConciseMethod(mock.functions.grail)
    sweet_method(1, 2)
    mock.functions.grail.assert_called_once_with(1, 2)
    # Checking in return_value, ie the function instance
    mock.functions.grail.return_value.call.assert_called_once_with({})
def test_concisecontract_custom_transact():
    mock = Mock()
    sweet_method = ConciseMethod(mock.functions.grail)
    sweet_method(1, 2, transact={'holy': 3})
    mock.functions.grail.assert_called_once_with(1, 2)
    # Checking in return_value, ie the function instance
    mock.functions.grail.return_value.transact.assert_called_once_with({'holy': 3})
Example #3
0
def test_concisecontract_unknown_keyword_fails():
    contract = Mock()
    sweet_method = ConciseMethod(contract.functions.grail)
    with pytest.raises(TypeError):
        sweet_method(1, 2, count={'to': 5})
Example #4
0
def test_concisecontract_two_keywords_fail():
    mock = Mock()
    sweet_method = ConciseMethod(mock)
    with pytest.raises(TypeError):
        sweet_method(1, 2, transact={'holy': 3}, call={'count_to': 4})