Example #1
0
def test_aws_client_pass_no_opt_args_substitutions(mock_waiter):
    """Successful run with no optional args substitutions."""
    context = Context({
        'k1': 'v1',
        'k2': 'v2',
        'k3': 'v3',
        'k4': 'v4',
        'k5': 'v5',
        'awsWaitIn': {
            'serviceName': 'service name {k1}',
            'waiterName': '{k2} waiter_name',
            'arbKey': 'arb_value'
        }
    })
    wait.run_step(context)

    assert len(context) == 6
    assert context['k1'] == 'v1'
    assert context['awsWaitIn'] == {
        'serviceName': 'service name {k1}',
        'waiterName': '{k2} waiter_name',
        'arbKey': 'arb_value'
    }

    mock_waiter.assert_called_once_with(service_name='service name v1',
                                        waiter_name='v2 waiter_name',
                                        waiter_args=None,
                                        wait_args=None)
Example #2
0
def test_aws_wait_pass_no_args(mock_waiter):
    """Successful run with no client args."""
    context = Context({
        'k1': 'v1',
        'awsWaitIn': {
            'serviceName': 'service name',
            'waiterName': 'waiter_name',
            'arbKey': 'arb_value'
        }
    })
    wait.run_step(context)

    assert len(context) == 2
    assert context['k1'] == 'v1'
    assert context['awsWaitIn'] == {
        'serviceName': 'service name',
        'waiterName': 'waiter_name',
        'arbKey': 'arb_value'
    }

    mock_waiter.assert_called_once_with(
        service_name='service name',
        waiter_name='waiter_name',
        waiter_args=None,
        wait_args=None,
    )
Example #3
0
def test_aws_client_pass_all_args_substitutions(mock_waiter):
    """Successful run with waiter and wait args substitutions"""
    context = Context({
        'k1': 'v1',
        'k2': 'v2',
        'k3': 'v3',
        'k4': 'v4',
        'k5': 'v5',
        'awsWaitIn': {
            'serviceName': 'service name {k1}',
            'waiterName': '{k2} waiter_name',
            'arbKey': 'arb_value',
            'waiterArgs': {'ck1 {k3}': 'cv1', 'ck2': '{k4} cv2'},
            'waitArgs': {'mk1': 'mv1', '{k5} mk2': 'mv2'}
        }})
    wait.run_step(context)

    assert len(context) == 6
    assert context['k1'] == 'v1'
    assert context['awsWaitIn'] == {
        'serviceName': 'service name {k1}',
        'waiterName': '{k2} waiter_name',
        'arbKey': 'arb_value',
        'waiterArgs': {'ck1 {k3}': 'cv1', 'ck2': '{k4} cv2'},
        'waitArgs': {'mk1': 'mv1', '{k5} mk2': 'mv2'}
    }

    mock_waiter.assert_called_once_with(service_name='service name v1',
                                        waiter_name='v2 waiter_name',
                                        waiter_args={'ck1 v3': 'cv1',
                                                     'ck2': 'v4 cv2'},
                                        wait_args={'mk1': 'mv1',
                                                    'v5 mk2': 'mv2'},
                                        )
Example #4
0
def test_aws_client_pass_all_args(mock_waiter):
    """Successful run with waiter and wait args"""
    context = Context({
        'k1': 'v1',
        'awsWaitIn': {
            'serviceName': 'service name',
            'waiterName': 'waiter_name',
            'arbKey': 'arb_value',
            'waiterArgs': {'ck1': 'cv1', 'ck2': 'cv2'},
            'waitArgs': {'mk1': 'mv1', 'mk2': 'mv2'}
        }})
    wait.run_step(context)

    assert len(context) == 2
    assert context['k1'] == 'v1'
    assert context['awsWaitIn'] == {
        'serviceName': 'service name',
        'waiterName': 'waiter_name',
        'arbKey': 'arb_value',
        'waiterArgs': {'ck1': 'cv1', 'ck2': 'cv2'},
        'waitArgs': {'mk1': 'mv1', 'mk2': 'mv2'}
    }

    mock_waiter.assert_called_once_with(service_name='service name',
                                        waiter_name='waiter_name',
                                        waiter_args={'ck1': 'cv1',
                                                     'ck2': 'cv2'},
                                        wait_args={'mk1': 'mv1',
                                                    'mk2': 'mv2'},
                                        )
Example #5
0
def test_aws_wait_missing_awswaitin():
    """Missing awsClientIn raises."""
    context = Context({'k1': 'v1'})

    with pytest.raises(KeyNotInContextError) as err_info:
        wait.run_step(context)

    assert str(err_info.value) == (
        "context['awsWaitIn'] doesn't exist. It must exist for "
        "pypyraws.steps.wait.")
Example #6
0
def test_aws_wait_missing_awswaitin():
    """Missing awsClientIn raises"""
    context = Context({'k1': 'v1'})

    with pytest.raises(KeyNotInContextError) as err_info:
        wait.run_step(context)

    assert repr(err_info.value) == (
        "KeyNotInContextError(\'awsWaitIn not found in the pypyr "
        "context.',)")