Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

3scale-api

Package Overview
Dependencies
Maintainers
4
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

3scale-api - npm Package Compare versions

Comparing version
0.35.2
to
0.35.3
+23
tests/integration/test_integration_account_plans.py
from tests.integration import asserts
def test_account_plans_list(api, account_plan):
account_plans = api.account_plans.list()
assert len(account_plans) >= 1
def test_account_plan_can_be_created(api, account_plan, account_plans_params):
asserts.assert_resource(account_plan)
asserts.assert_resource_params(account_plan, account_plans_params)
def test_account_plan_can_be_read(api, account_plan, account_plans_params):
read = api.account_plans.read(account_plan.entity_id)
asserts.assert_resource(read)
asserts.assert_resource_params(read, account_plans_params)
def test_account_plan_update(account_plan, account_plans_update_params):
updated_account_plan = account_plan.update(params=account_plans_update_params)
asserts.assert_resource(updated_account_plan)
asserts.assert_resource_params(updated_account_plan, account_plans_update_params)
from tests.integration import asserts
from tests.integration.conftest import account
def test_account_user_can_be_created(account_user, account_user_params):
asserts.assert_resource(account_user)
asserts.assert_resource_params(account_user, account_user_params)
def test_account_users_list(api,account, account_user):
users = account.users.list()
assert len(users) > 1
def test_account_users_get_by_id(account, account_user, account_user_params):
account_user = account.users.read(account_user['id'])
asserts.assert_resource(account_user)
asserts.assert_resource_params(account_user, account_user_params)
def test_account_user_can_be_updated(account_user, account_user_update_params):
updated_user = account_user.update(account_user_update_params)
asserts.assert_resource(updated_user)
asserts.assert_resource_params(updated_user, account_user_update_params)
def test_account_user_change_status(account_user):
assert account_user['state'] == 'pending'
updated_account_user = account_user.activate()
assert updated_account_user['state'] == 'active'
updated_account_user = account_user.suspend()
assert updated_account_user['state'] == 'suspended'
updated_account_user = account_user.un_suspend()
assert updated_account_user['state'] == 'active'
def test_account_user_change_role(account_user):
assert account_user['role'] == 'member'
updated_account_user = account_user.set_as_admin()
assert updated_account_user['role'] == 'admin'
updated_account_user = account_user.set_as_member()
assert updated_account_user['role'] == 'member'
from tests.integration import asserts
from tests.integration.conftest import backend
def test_backend_usage_can_be_created(backend_usage, backend_usage_params):
asserts.assert_resource(backend_usage)
asserts.assert_resource_params(backend_usage, backend_usage_params, [param for param in backend_usage_params.keys() if param != 'backend_api_id'])
def test_backend_usages_list(api, backend_usage, backend):
assert len(backend.usages()) >= 1
def test_backend_usage_update(backend_usage, backend, backend_usage_update_params):
updated_backend_usage = backend_usage.update(backend_usage_update_params)
asserts.assert_resource(updated_backend_usage)
asserts.assert_resource_params(updated_backend_usage, backend_usage_update_params, [param for param in backend_usage_update_params.keys() if param != 'backend_api_id'])
def test_x_served_by(api):
response = api._rest.get(url=api.admin_api_url + '/accounts')
assert response.status_code == 200
assert "X-Served-By" not in response.headers
from tests.integration import asserts
def test_list_service_plans(service):
resource = service.service_plans.list()
assert len(resource) >= 1
def test_check_service_plan_creation(service_plan, service_plan_params):
asserts.assert_resource(service_plan)
asserts.assert_resource_params(service_plan, service_plan_params)
assert service_plan.exists()
def test_read_service_plans(service, service_plan, service_plan_params):
asserts.assert_resource(service_plan)
resource = service.service_plans.read(service_plan.entity_id)
asserts.assert_resource(resource)
asserts.assert_resource_params(service_plan,service_plan_params)
def test_update_service_plans(service, service_plan, service_plan_params):
asserts.assert_resource(service_plan)
service_plan['state'] = 'publish'
service_plan['approval_required'] = True
resource = service.service_plans.update(service_plan.entity_id, service_plan_params)
asserts.assert_resource(resource)
asserts.assert_resource_params(service_plan, service_plan_params)
def test_set_default_service_plan(service_plan, service_plan_params):
asserts.assert_resource(service_plan)
resource = service_plan.set_default()
asserts.assert_resource(resource)
asserts.assert_resource_params(service_plan, service_plan_params)
from tests.integration import asserts
def test_list_service_subscriptions(account):
resource = account.service_subscriptions.list()
assert len(resource) >= 1
def test_create_service_subscription(service_subscription, service_subscription_params):
asserts.assert_resource(service_subscription)
asserts.assert_resource_params(service_subscription, service_subscription_params)
def test_read_service_subscription(account, service_subscription, service_subscription_params):
resource = account.service_subscriptions.read(service_subscription.entity_id)
asserts.assert_resource(resource)
asserts.assert_resource_params(service_subscription,service_subscription_params)
def test_change_plan_service_subscription(account, account_plan, service_plan,
service_subscription):
asserts.assert_resource(account)
asserts.assert_resource(account_plan)
asserts.assert_resource(service_plan)
account.service_subscriptions.change_plan(service_subscription.entity_id,
service_plan.entity_id)
def test_approve_service_subscription(account, service_subscription, service_plan):
asserts.assert_resource(service_subscription)
asserts.assert_resource(account)
asserts.assert_resource(service_plan)
resource = service_subscription.approve()
asserts.assert_resource(resource)
+12
-5
Metadata-Version: 2.1
Name: 3scale-api
Version: 0.35.2
Version: 0.35.3
Summary: 3scale API python client
Home-page: https://github.com/pestanko/3scale-api-python
Home-page: https://github.com/3scale-qe/3scale-api-python
Author: Peter Stanko
Author-email: stanko@mail.muni.cz
Maintainer: Peter Stanko
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Maintainer: Matej Dujava
Maintainer-email: mdujava@redhat.com
Classifier: Operating System :: OS Independent

@@ -15,2 +14,10 @@ Classifier: License :: OSI Approved :: Apache Software License

Classifier: Topic :: Utilities
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Description-Content-Type: text/markdown

@@ -17,0 +24,0 @@ Provides-Extra: dev

@@ -13,2 +13,4 @@ LICENSE

tests/integration/test_integration_access_token.py
tests/integration/test_integration_account_plans.py
tests/integration/test_integration_account_users.py
tests/integration/test_integration_accounts.py

@@ -23,2 +25,3 @@ tests/integration/test_integration_activedocs.py

tests/integration/test_integration_backend_metrics.py
tests/integration/test_integration_backend_usages.py
tests/integration/test_integration_backends.py

@@ -38,2 +41,5 @@ tests/integration/test_integration_cms.py

tests/integration/test_integration_provider_account_users.py
tests/integration/test_integration_response_headers.py
tests/integration/test_integration_service_plans.py
tests/integration/test_integration_service_subscriptions.py
tests/integration/test_integration_services.py

@@ -40,0 +46,0 @@ tests/integration/test_integration_tenant.py

Metadata-Version: 2.1
Name: 3scale-api
Version: 0.35.2
Version: 0.35.3
Summary: 3scale API python client
Home-page: https://github.com/pestanko/3scale-api-python
Home-page: https://github.com/3scale-qe/3scale-api-python
Author: Peter Stanko
Author-email: stanko@mail.muni.cz
Maintainer: Peter Stanko
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Maintainer: Matej Dujava
Maintainer-email: mdujava@redhat.com
Classifier: Operating System :: OS Independent

@@ -15,2 +14,10 @@ Classifier: License :: OSI Approved :: Apache Software License

Classifier: Topic :: Utilities
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Description-Content-Type: text/markdown

@@ -17,0 +24,0 @@ Provides-Extra: dev

+32
-33

@@ -15,37 +15,36 @@ import re

requirements = ['requests', 'backoff']
requirements = ["requests", "backoff"]
extra_requirements = {
'dev': [
'pytest',
'coverage',
'python-dotenv',
'responses'
extra_requirements = {"dev": ["pytest", "coverage", "python-dotenv", "responses"], "docs": ["sphinx"]}
setup(
name="3scale-api",
version=VERSION,
description="3scale API python client",
author="Peter Stanko",
author_email="stanko@mail.muni.cz",
maintainer="Matej Dujava",
maintainer_email="mdujava@redhat.com",
url="https://github.com/3scale-qe/3scale-api-python",
packages=find_packages(exclude=("tests",)),
long_description=long_description,
long_description_content_type="text/markdown",
include_package_data=True,
install_requires=requirements,
extras_require=extra_requirements,
entry_points={},
classifiers=[
"Operating System :: OS Independent",
"License :: OSI Approved :: Apache Software License",
"Intended Audience :: Developers",
"Topic :: Utilities",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
],
'docs': ['sphinx']
}
setup(name='3scale-api',
version=VERSION,
description='3scale API python client',
author='Peter Stanko',
author_email='stanko@mail.muni.cz',
maintainer='Peter Stanko',
url='https://github.com/pestanko/3scale-api-python',
packages=find_packages(exclude=("tests",)),
long_description=long_description,
long_description_content_type='text/markdown',
include_package_data=True,
install_requires=requirements,
extras_require=extra_requirements,
entry_points={},
classifiers=[
"Programming Language :: Python :: 3",
'Programming Language :: Python :: 3.7',
"Operating System :: OS Independent",
"License :: OSI Approved :: Apache Software License",
'Intended Audience :: Developers',
'Topic :: Utilities',
],
)
)

@@ -22,9 +22,12 @@ from typing import List

def assert_resource_params(obj: threescale_api.defaults.DefaultResource, params: dict, allowed=None):
if allowed is None:
allowed = params.keys()
for (key, val) in params.items():
if allowed is not None and key in allowed:
assert obj[key] == val, f"Resource value for key \"{key}\" should be correct."
assert obj.entity[key] == val, "Entity value for key \"{key}\" should be correct."
if key in allowed:
assert obj[key] == val, f"Resource hasn't got expected value for a \"{key}\". {obj[key]} == {val}"
assert obj.entity[key] == val, "Entity hasn't got expected value for key \"{key}\". {obj.entity[key]} == {val}"
def assert_http_ok(response: requests.Response):
assert response.status_code == 200

@@ -14,5 +14,6 @@ import os

Proxy, Backend, Metric, MappingRule,
BackendMappingRule, BackendUsage,
BackendMappingRule, Account, BackendUsage,
ActiveDoc, Webhooks, InvoiceState,
ApplicationKey)
ApplicationKey, ApplicationPlans, AccountUser, AccountUsers, ServiceSubscription,
ServicePlan)

@@ -107,6 +108,18 @@ load_dotenv()

@pytest.fixture(scope='module')
def update_account_params():
suffix = secrets.token_urlsafe(8)
name = f"updated-{suffix}"
return dict(org_name=name)
@pytest.fixture(scope='module')
def account_get_plan_params():
return dict(name="Default")
@pytest.fixture(scope='module')
def account_params():
suffix = get_suffix()
name = f"test-{suffix}"
return dict(name=name, username=name, org_name=name)
return dict(username=name, org_name=name)

@@ -122,2 +135,43 @@

@pytest.fixture(scope='module')
def account_user_update_params():
suffix = get_suffix()
name = f"test-update-{suffix}"
return dict(username=name, email=f"{name}@email.com")
@pytest.fixture(scope='module')
def account_user_params():
suffix = get_suffix()
name = f"test-{suffix}"
return dict(username=name, email=f"{name}@email.com")
@pytest.fixture(scope='module')
def account_user(account,account_user_params) -> AccountUser:
user = account.users.create(account_user_params)
yield user
cleanup(user)
@pytest.fixture(scope='module')
def service_plan_params() -> dict:
suffix = get_suffix()
return {"name":f'test-{suffix}', "approval_required": True}
@pytest.fixture(scope='module')
def service_plan(service, service_plan_params) -> ServicePlan:
resource = service.service_plans.create(params=service_plan_params)
yield resource
cleanup(resource)
@pytest.fixture(scope='module')
def service_subscription_params(service_plan) -> dict:
return {"plan_id":service_plan['id']}
@pytest.fixture(scope='module')
def service_subscription(account, service_subscription_params) -> ServiceSubscription:
resource = account.service_subscriptions.create(params=service_subscription_params)
yield resource
cleanup(resource)
@pytest.fixture(scope='module')
def application_plan_params() -> dict:

@@ -133,3 +187,8 @@ suffix = get_suffix()

@pytest.fixture(scope='module')
def application_plans(api) -> ApplicationPlans:
application_plans = api.application_plans
yield application_plans
@pytest.fixture(scope='module')

@@ -151,3 +210,3 @@ def application_params(application_plan):

def app_key_params(account, application):
value = ''.join(random.choices(string.ascii_uppercase + string.digits + '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~', k=100))
value = ''.join(random.choices(string.ascii_uppercase + string.digits + '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~', k=255))
return({"application_id": application["id"], "account_id": account["id"], "key": value})

@@ -175,9 +234,14 @@

@pytest.fixture(scope='module')
def backend_usage(service, backend, application) -> BackendUsage:
params = {
'service_id': service['id'],
'backend_api_id': backend['id'],
'path': '/get',
}
resource = service.backend_usages.create(params=params)
def backend_usage_update_params(service, backend):
return dict(service_id=service['id'], backend_api_id=backend['id'], path='/put')
@pytest.fixture(scope='module')
def backend_usage_params(service, backend):
return dict(service_id=service['id'], backend_api_id=backend['id'], path='/get')
@pytest.fixture(scope='module')
def backend_usage(service, backend, application, backend_usage_params) -> BackendUsage:
resource = service.backend_usages.create(params=backend_usage_params)
yield resource

@@ -198,13 +262,12 @@ cleanup(resource)

friendly_name = f'test-metric-{suffix}'
system_name = f'{friendly_name}'.replace('-', '_')
return dict(backend_id=backend['id'], friendly_name=friendly_name,
system_name=system_name, unit='count')
unit='count')
@pytest.fixture
def updated_metric_params(metric_params):
params = metric_params.copy()
suffix = get_suffix()
friendly_name = f'test-updated-metric-{suffix}'
metric_params['friendly_name'] = f'/anything/{friendly_name}'
metric_params['system_name'] = friendly_name.replace('-', '_')
return metric_params
params['friendly_name'] = f'/anything/{friendly_name}'
return params

@@ -216,3 +279,2 @@ @pytest.fixture

backend_metric_params['friendly_name'] = f'/anything/{friendly_name}'
backend_metric_params['system_name'] = friendly_name.replace('-', '_')
return backend_metric_params

@@ -243,5 +305,3 @@

friendly_name = f'test-method-{suffix}'
system_name = f'{friendly_name}'.replace('-', '_')
return dict(friendly_name=friendly_name, system_name=system_name,
unit='hits')
return dict(friendly_name=friendly_name)

@@ -254,3 +314,2 @@

method_params['friendly_name'] = friendly_name
method_params['system_name'] = f'{friendly_name}'.replace('-', '_')
return method_params

@@ -400,7 +459,7 @@

@pytest.fixture(scope='module')
def backend_metric(backend, metric_params, proxy) -> Metric:
def backend_metric(backend, backend_metric_params, proxy) -> Metric:
"""
Fixture for getting backend metric.
"""
resource = backend.metrics.create(params=metric_params)
resource = backend.metrics.create(params=backend_metric_params)
yield resource

@@ -436,3 +495,19 @@ for map_rule in backend.mapping_rules.select_by(metric_id=resource['id']):

@pytest.fixture(scope='module')
def active_docs_update_body():
return """
{"swagger":"2.0","info":{"version":"1.0.1","title":"Test"},"paths":{"/test":{"get":{"operationId":"Test",
"parameters":[],"responses":{"400":{"description":"bad input parameters"}}}}},"definitions":{}}
"""
@pytest.fixture(scope='module')
def active_docs_update_params(active_docs_update_body):
suffix = get_suffix()
name = f"updated-{suffix}"
return dict(name=name, body=active_docs_update_body)
@pytest.fixture(scope='module')
def active_docs_body():

@@ -477,3 +552,3 @@ return """

email=f'{name}@example.com',
assword='123456')
password='123456')

@@ -494,2 +569,9 @@

@pytest.fixture(scope='module')
def account_plans_update_params():
suffix = secrets.token_urlsafe(8)
name = f"updated-{suffix}"
return dict(name=name)
@pytest.fixture(scope='module')
def account_plans_params():

@@ -536,3 +618,3 @@ suffix = get_suffix()

target="Account",
required="false")
required=False)

@@ -615,6 +697,7 @@

"""CMS page fixture params"""
# section_name or section_id can be used to identify section
# layout_name or layout_id can be used to identify section
return {"system_name": f"sname-{get_suffix()}", "draft": f"draft-{get_suffix()}",
"title": f"title-{get_suffix()}", "path": f"/path-{get_suffix()}",
"section_name": f"section-{get_suffix()}", "section_id": cms_section['id'],
"layout_name": f"layout-{get_suffix()}", "layout_id": cms_layout['id'],
"section_id": cms_section['id'], "layout_id": cms_layout['id'],
"liquid_enabled": True, "handler": "markdown", "content_type": "text/html"}

@@ -621,0 +704,0 @@

@@ -11,3 +11,3 @@ from tests.integration import asserts

asserts.assert_resource(account)
asserts.assert_resource_params(account, account_params)
asserts.assert_resource_params(account, account_params, ['org_name'])

@@ -18,3 +18,3 @@

asserts.assert_resource(read)
asserts.assert_resource_params(read, account_params)
asserts.assert_resource_params(read, account_params, ['org_name'])

@@ -26,5 +26,24 @@

asserts.assert_resource(read)
asserts.assert_resource_params(read, account_params)
asserts.assert_resource_params(read, account_params, ['org_name'])
def test_account_can_be_find_by_name(api, account_user, account_params):
account2 = api.accounts.find(dict(username=account_user['username']))
asserts.assert_resource(account2)
asserts.assert_resource_params(account2, account_params, ['org_name'])
def test_account_update(api,account, update_account_params):
updated_account = account.update(params=update_account_params)
asserts.assert_resource(updated_account)
asserts.assert_resource_params(updated_account, update_account_params)
def test_get_account_plan(account, account_get_plan_params):
plan = account.get_account_plan()
asserts.assert_resource(plan)
asserts.assert_resource_params(plan,account_get_plan_params, ['name'])
def test_users_list(api, account):
assert len(account.users.list()) >= 1
from tests.integration import asserts
from .asserts import assert_resource, assert_resource_params
def test_active_docs_can_be_created(active_doc, active_docs_params):
asserts.assert_resource(active_doc)
asserts.assert_resource_params(active_doc, active_docs_params)
def test_active_docs_fetch(active_doc):

@@ -8,1 +13,12 @@ ac = active_doc.client.fetch(int(active_doc['id']))

assert ac['id'] == active_doc['id']
def test_active_docs_list(api, active_doc):
active_docs = api.active_docs.list()
assert len(active_docs) >= 1
def test_active_docs_update(active_doc, active_docs_update_params):
updated_active_doc = active_doc.update(params=active_docs_update_params)
asserts.assert_resource(updated_active_doc)
asserts.assert_resource_params(updated_active_doc, active_docs_update_params)

@@ -10,3 +10,3 @@ import pytest

suffix = secrets.token_urlsafe(8)
return dict(name=f"updated-{suffix}", cost_per_month='12.0', setup_fee='50.0')
return dict(name=f"updated-{suffix}", cost_per_month=12.0, setup_fee=50.0)

@@ -28,1 +28,6 @@

asserts.assert_resource_params(updated_app_plan, update_params)
def test_application_plans_list_all(application_plans):
app_plans = application_plans.list()
assert len(app_plans) >= 1
import random
import string
import base64
import secrets

@@ -34,3 +35,3 @@ import pytest

asserts.assert_resource(app_key)
asserts.assert_resource_params(app_key, app_key_params)
assert app_key["value"] == app_key_params["key"]

@@ -42,6 +43,15 @@

def test_application_update_userkey(application):
new_key = "".join(random.choices(string.ascii_letters + string.digits + "-_.", k=100))
new_key = "".join(random.choices(string.ascii_letters + string.digits + "-_.", k=255))
updated_application = application.update(params={"user_key": new_key})
asserts.assert_resource(updated_application)
assert updated_application["user_key"] == new_key
def test_application_update_userkey_base64(application):
new_key = "".join(random.choices(string.ascii_letters + string.digits + "-_.", k=41))
new_key = base64.b64encode(new_key.encode('ascii')).decode()
updated_application = application.update(params={"user_key": new_key})
asserts.assert_resource(updated_application)
assert updated_application["user_key"] == new_key

@@ -11,3 +11,3 @@ import pytest

asserts.assert_resource(backend_metric)
asserts.assert_resource_params(backend_metric, backend_metric_params)
asserts.assert_resource_params(backend_metric, backend_metric_params, [param for param in backend_metric_params.keys() if param != 'backend_id'])

@@ -20,4 +20,5 @@ def test_should_fields_be_required(backend):

def test_should_system_name_be_invalid(backend, backend_metric_params):
backend_metric_params['system_name'] = 'invalid name whitespaces'
resource = backend.metrics.create(params=backend_metric_params, throws=False)
params = backend_metric_params.copy()
params['system_name'] = 'invalid name whitespaces'
resource = backend.metrics.create(params=params, throws=False)
asserts.assert_errors_contains(resource, ['system_name'])

@@ -34,3 +35,3 @@

asserts.assert_resource(resource)
asserts.assert_resource_params(resource, backend_metric_params)
asserts.assert_resource_params(resource, backend_metric_params, [param for param in backend_metric_params.keys() if param != 'backend_id'])

@@ -41,3 +42,3 @@

asserts.assert_resource(resource)
asserts.assert_resource_params(resource, backend_updated_metric_params)
asserts.assert_resource_params(resource, backend_updated_metric_params, [param for param in backend_updated_metric_params.keys() if param != 'backend_id'])

@@ -44,0 +45,0 @@

@@ -54,1 +54,4 @@ from tests.integration import asserts

assert backend.usages() == [backend_usage]
def test_backend_annotation(backend):
assert backend['annotations'] == {}

@@ -14,1 +14,5 @@ from .asserts import assert_resource

assert custom_tenant.entity["signup"]["access_token"]["value"]
def test_tenant_annotation(custom_tenant):
assert custom_tenant["signup"]["account"]["annotations"] == {}

@@ -23,3 +23,3 @@ from .asserts import assert_resource, assert_resource_params

update_params = dict(target="Cinstance", label="something_else",
hidden="true", read_only="true", position=1)
hidden=True, read_only=True, position=1)
updated = fields_definition.update(update_params)

@@ -26,0 +26,0 @@ assert_resource_params(updated, update_params)

@@ -29,10 +29,2 @@ import pytest

def test_invoice_update(invoice, api):
assert invoice['state'] == 'open'
update = api.invoices.update(invoice.entity_id, dict(friendly_id='1111-11111111'))
assert update['friendly_id'] == '1111-11111111'
read = api.invoices.read(invoice.entity_id)
assert read['friendly_id'] == '1111-11111111'
def test_invoice_list_by_account(api, account, invoice):

@@ -51,2 +43,10 @@ invoices = api.invoices.list_by_account(account.entity_id)

def test_invoice_update(invoice, api):
assert invoice['state'] == 'open'
update = api.invoices.update(invoice.entity_id, dict(friendly_id='1111-11111111'))
assert update['friendly_id'] == '1111-11111111'
read = api.invoices.read(invoice.entity_id)
assert read['friendly_id'] == '1111-11111111'
def test_invoice_update_state(invoice_to_update, api):

@@ -53,0 +53,0 @@ assert invoice_to_update['state'] == 'open'

@@ -13,3 +13,3 @@ import pytest

asserts.assert_resource(metric)
asserts.assert_resource_params(metric, metric_params)
asserts.assert_resource_params(metric, metric_params, [param for param in metric_params.keys() if param != 'service_id'])

@@ -23,4 +23,5 @@

def test_should_system_name_be_invalid(service, metric_params):
metric_params['system_name'] = 'invalid name whitespaces'
resource = service.metrics.create(params=metric_params, throws=False)
params = metric_params.copy()
params['system_name'] = 'invalid name whitespaces'
resource = service.metrics.create(params=params, throws=False)
asserts.assert_errors_contains(resource, ['system_name'])

@@ -37,3 +38,3 @@

asserts.assert_resource(resource)
asserts.assert_resource_params(resource, metric_params)
asserts.assert_resource_params(resource, metric_params, [param for param in metric_params.keys() if param != 'service_id'])

@@ -44,13 +45,6 @@

asserts.assert_resource(resource)
asserts.assert_resource_params(resource, updated_metric_params)
asserts.assert_resource_params(resource, updated_metric_params, [param for param in updated_metric_params.keys() if param != 'service_id'])
def test_should_delete_metric(service, updated_metric_params):
resource = service.metrics.create(params=updated_metric_params)
assert resource.exists()
resource.delete()
assert not resource.exists()
def test_should_list_metrics(service):
def test_should_list_metrics(service, metric):
resources = service.metrics.list()

@@ -61,3 +55,3 @@ assert len(resources) > 1

def test_should_apicast_return_403_when_metric_is_disabled(
service, metric_params, create_mapping_rule,
service, metric, create_mapping_rule,
account, ssl_verify, backend_usage):

@@ -72,3 +66,2 @@ """Metric is disabled when its limit is set to 0."""

metric = service.metrics.create(params=metric_params)
plan.limits(metric).create(params=dict(period='month', value=0))

@@ -75,0 +68,0 @@

@@ -6,3 +6,3 @@ from tests.integration import asserts

asserts.assert_resource(provider_account_user)
asserts.assert_resource_params(provider_account_user, provider_account_params)
asserts.assert_resource_params(provider_account_user, provider_account_params, [param for param in provider_account_params.keys() if param != 'password'])

@@ -18,3 +18,3 @@

asserts.assert_resource(account)
asserts.assert_resource_params(account, provider_account_params)
asserts.assert_resource_params(account, provider_account_params, [param for param in provider_account_params.keys() if param != 'password'])

@@ -21,0 +21,0 @@

@@ -119,2 +119,6 @@ from tests.integration import asserts

def test_service_active_docs(service, active_doc):
assert all([acs['service_id'] == service['id'] for acs in service.active_docs.list()])
assert all(acs['service_id'] == service['id'] for acs in service.active_docs.list())
def test_service_annotation(service):
assert service['annotations'] == {}

@@ -40,2 +40,4 @@ import logging

self._active_docs = resources.ActiveDocs(self, instance_klass=resources.ActiveDoc)
self._application_plans = \
resources.ApplicationPlans(self, instance_klass=resources.ApplicationPlan)
self._account_plans = resources.AccountPlans(self, instance_klass=resources.AccountPlan)

@@ -147,2 +149,9 @@ self._settings = resources.SettingsClient(self)

@property
def application_plans(self) -> resources.ApplicationPlans:
"""Get applications_plan client
Returns(resources.ApplicationPlans): ApplicationPlans client
"""
return self._application_plans
@property
def services(self) -> resources.Services:

@@ -253,3 +262,3 @@ """Gets services client

@property
def policy_registry(self) -> resources.PolicyRegistry:
def policy_registry(self) -> resources.PoliciesRegistry:
return self._policy_registry

@@ -256,0 +265,0 @@

@@ -519,2 +519,12 @@ import logging

def un_suspend(self, **kwargs) -> 'DefaultUserResource':
"""Un suspends the user
Args:
**kwargs:
Optional arguments
Returns(DefaultUserResource): User instance
"""
return self.set_state(state='unsuspend', **kwargs)
def resume(self, **kwargs):

@@ -545,3 +555,3 @@ """Resumes the user

"""
return self.set_state(state='set_as_admin', **kwargs)
return self.set_state(state='admin', **kwargs)

@@ -555,2 +565,2 @@ def set_as_member(self, **kwargs):

"""
return self.set_state(state='set_as_member', **kwargs)
return self.set_state(state='member', **kwargs)

Sorry, the diff of this file is too big to display