Ejemplo n.º 1
0
def test_get_tier_config(get_mock):
    get_mock.return_value = _get_tier_config_response()
    tier_config = Directory().get_tier_config('TC-000-000-000')
    assert isinstance(tier_config, TierConfig)
    assert tier_config.id == 'TC-000-000-000'

    get_mock.assert_called_with(
        url='http://localhost:8080/api/public/v1/tier/configs/TC-000-000-000',
        headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'})
Ejemplo n.º 2
0
def test_get_asset(get_mock):
    get_mock.return_value = _get_asset_response()
    asset = Directory().get_asset('AS-9861-7949-8492')
    assert isinstance(asset, Asset)
    assert asset.id == 'AS-9861-7949-8492'

    get_mock.assert_called_with(
        url='http://localhost:8080/api/public/v1/assets/AS-9861-7949-8492',
        headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'})
Ejemplo n.º 3
0
def test_get_product(get_mock):
    get_mock.return_value = _get_product_response()
    product = Directory().get_product('CN-783-317-575')
    assert isinstance(product, Product)
    assert product.id == 'CN-783-317-575'

    get_mock.assert_called_with(
        url='http://localhost:8080/api/public/v1/products/CN-783-317-575',
        headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'})
Ejemplo n.º 4
0
def test_list_products(get_mock):
    get_mock.return_value = _get_array_response(_get_product_response())
    products = Directory().list_products()
    assert isinstance(products, list)
    assert len(products) == 1
    assert isinstance(products[0], Product)
    assert products[0].id == 'CN-783-317-575'

    get_mock.assert_called_with(
        url='http://localhost:8080/api/public/v1/products',
        headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'})
Ejemplo n.º 5
0
    def get_tier_partner_data(self, account_id=None):
        """Look for domain name in tier1 configuration data. `partner_id` keeps this information for us"""

        filters = Query().equal('account.id', account_id)
        configs = list(Directory().list_tier_configs(filters))

        for config in configs:
            for param in config.params:
                if param.id == 'partner_id':
                    return param

        return None
Ejemplo n.º 6
0
def test_list_assets(get_mock):
    get_mock.return_value = _get_array_response(_get_asset_response())
    assets = Directory().list_assets()
    assert isinstance(assets, list)
    assert len(assets) == 1
    assert isinstance(assets[0], Asset)
    assert assets[0].id == 'AS-9861-7949-8492'

    get_mock.assert_called_with(
        url='http://localhost:8080/api/public/v1/assets?in(product.id,(CN-631-322-000))',
        headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'},
        params=None)
Ejemplo n.º 7
0
def test_list_tier_configs(get_mock):
    get_mock.return_value = _get_array_response(_get_tier_config_response())
    tier_configs = Directory().list_tier_configs()
    assert isinstance(tier_configs, list)
    assert len(tier_configs) == 1
    assert isinstance(tier_configs[0], TierConfig)
    assert tier_configs[0].id == 'TC-000-000-000'

    get_mock.assert_called_with(
        url='http://localhost:8080/api/public/v1/tier/configs',
        headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'},
        params={'product.id': 'CN-631-322-000'})
Ejemplo n.º 8
0
def test_get_asset_bad():
    with pytest.raises(ServerError):
        Directory().get_asset('AS-9861-7949-8492')
Ejemplo n.º 9
0
def test_get_tier_config_bad():
    with pytest.raises(ServerError):
        Directory().get_tier_config('TC-000-000-000')
Ejemplo n.º 10
0
def test_get_product_bad():
    with pytest.raises(ServerError):
        Directory().get_product('CN-783-317-575')