Beispiel #1
0
def mock_rest_client(monkeypatch, mock_config, mock_wallet):
    """ Fixture that injects a MockTwentyOneRestClient

    Returns:
        MockTwentyOneRestClient: an mock rest client initialized with a mock config and mock wallet
    """
    machine_auth = MachineAuthWallet(mock_wallet)
    _mock_rest_client = mock_objects.MockTwentyOneRestClient(
        None, machine_auth, mock_config.username)
    for func_name in mock_objects.MockTwentyOneRestClient.DEFAULT_VALUES.keys(
    ):
        monkeypatch.setattr(server.rest_client.TwentyOneRestClient, func_name,
                            getattr(_mock_rest_client, func_name))
    return _mock_rest_client
Beispiel #2
0
def patch_rest_client(monkeypatch, mock_config, mock_wallet):
    """ Fixture that injects a MockTwentyOneRestClient that monkeypathces the regular TwentyOneRestClient

    Returns:
        MockTwentyOneRestClient: a mock rest client object
    """
    machine_auth = MachineAuthWallet(mock_wallet)
    _patch_rest_client = mock_objects.MockTwentyOneRestClient(
        None, machine_auth, mock_config.username)
    for mock_function in mock_objects.MockTwentyOneRestClient.DEFAULT_VALUES.keys(
    ):
        monkeypatch.setattr(server.rest_client.TwentyOneRestClient,
                            mock_function,
                            getattr(_patch_rest_client, mock_function))
    return _patch_rest_client