Beispiel #1
0
def test_delete_label(routemaster_api: RoutemasterAPI):
    httpretty.register_uri(
        httpretty.DELETE,
        'http://localhost:2017/state-machines/testing-machine/labels/demo-label',
        content_type='application/json',
        status=204,
    )

    label_ref = LabelRef(
        LabelName('demo-label'),
        StateMachine('testing-machine'),
    )

    routemaster_api.delete_label(label_ref)
Beispiel #2
0
def test_delete_label_error_response(routemaster_api: RoutemasterAPI):
    httpretty.register_uri(
        httpretty.DELETE,
        'http://localhost:2017/state-machines/testing-machine/labels/demo-label',
        content_type='application/json',
        status=502,
    )

    label_ref = LabelRef(
        LabelName('demo-label'),
        StateMachine('testing-machine'),
    )

    with pytest.raises(requests.HTTPError):
        routemaster_api.delete_label(label_ref)
Beispiel #3
0
def test_delete_label_unknown_state_machine(routemaster_api: RoutemasterAPI):
    # Note: the update API doesn't differentiate between an unknown label and an
    # unknown state machine.
    httpretty.register_uri(
        httpretty.DELETE,
        'http://localhost:2017/state-machines/none/labels/demo-label',
        content_type='application/json',
        status=404,
    )

    testing_machine = StateMachine('none')
    label_ref = LabelRef(LabelName('demo-label'), testing_machine)

    with pytest.raises(UnknownStateMachine) as e:
        routemaster_api.delete_label(label_ref)

    assert e.value.state_machine == 'none'