Exemplo n.º 1
0
def test_spotinst_account_resolution_failure():
    with responses.RequestsMock() as rsps:
        rsps.add(rsps.GET, '{}/setup/account?awsAccountId=12345'.format(SPOTINST_API_URL), status=200,
                 json={"response": {
                     "items": [],
                 }})

        with pytest.raises(MissingSpotinstAccount):
            resolve_account_id("fake-token", "12345")
Exemplo n.º 2
0
def test_spotinst_account_resolution():
    with responses.RequestsMock() as rsps:
        rsps.add(rsps.GET, '{}/setup/account?awsAccountId=12345'.format(SPOTINST_API_URL), status=200,
                 json={"response": {
                     "items": [
                         {"accountId": "act-1234abcd", "name": "expected-match"},
                         {"accountId": "act-xyz", "name": "second-match"}
                     ],
                 }})

        account_id = resolve_account_id("fake-token", "12345")
        assert account_id == "act-1234abcd"