How to use the aiogoogle.resource.GoogleAPI function in aiogoogle

To help you get started, we’ve selected a few aiogoogle examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github omarryhan / aiogoogle / tests / test_units / test_auth / test_oauth2.py View on Github external
def test_oauth2_manager_has_valid_oauth2_api(manager):
    assert isinstance(manager.oauth2_api, GoogleAPI)
github omarryhan / aiogoogle / tests / test_units / test_GoogleAPI.py View on Github external
def test_properties(open_discovery_document, name, version):
    discovery_document = open_discovery_document(name, version)
    api = GoogleAPI(discovery_document=discovery_document)
    assert (name in str(api)) or (discovery_document.get("title") in str(api))
    assert (version in str(api)) or (discovery_document.get("title") in str(api))
github omarryhan / aiogoogle / tests / test_units / test_discovery_client.py View on Github external
def test_getitem(open_discovery_document, name, version):
    discovery_document = open_discovery_document(name, version)
    api = GoogleAPI(discovery_document=discovery_document)
    assert api['name'] == discovery_document.get('name')
    assert api['version'] == discovery_document.get('version')
    assert api['auth'] == discovery_document.get('auth')
github omarryhan / aiogoogle / tests / test_units / test_GoogleAPI_Resource.py View on Github external
def test_resource_returns_nested_resource(open_discovery_document, name, version):
    discovery_document = open_discovery_document(name, version)
    api = GoogleAPI(discovery_document=discovery_document)
    for resource_name, _ in discovery_document.get("resources", {}).items():
        resource = getattr(api, resource_name)
        if resource.resources_available:
            # Assert that it returns resources not methods
            for nested_resource_name in resource.resources_available:
                nested_resource = getattr(resource, nested_resource_name)
                assert isinstance(nested_resource, Resource)
github omarryhan / aiogoogle / tests / test_units / test_GoogleAPI_Method.py View on Github external
def test_required_parameters_are_filtered_correctly(
    open_discovery_document, name, version
):
    discovery_document = open_discovery_document(name, version)
    api = GoogleAPI(discovery_document=discovery_document)
    for resource_name, _ in discovery_document.get("resources").items():
        resource = getattr(api, resource_name)
        for method_name in resource.methods_available:
            method = resource._get_method(method_name)
            for parameter_name in method.required_parameters:
                parameter = method.parameters[parameter_name]
                assert parameter.get("required") is True
github omarryhan / aiogoogle / tests / test_units / test_GoogleAPI_Resource.py View on Github external
def test_stack_parameters_are_passed_correctly(open_discovery_document, name, version):
    discovery_document = open_discovery_document(name, version)
    api = GoogleAPI(discovery_document=discovery_document)
    for resource_name, _ in discovery_document.get("resources").items():
        resource = getattr(api, resource_name)
        for param_name in STACK_QUERY_PARAMETERS:
            assert param_name in resource._global_parameters
            assert (
                resource._global_parameters[param_name]
                == STACK_QUERY_PARAMETER_DEFAULT_VALUE
            )
github omarryhan / aiogoogle / tests / test_units / test_GoogleAPI_Resource.py View on Github external
def test_calling_resource_fails(open_discovery_document, name, version):
    discovery_document = open_discovery_document(name, version)
    api = GoogleAPI(discovery_document=discovery_document)
    for resource_name, _ in discovery_document.get("resources").items():
        resource = getattr(api, resource_name)
        with pytest.raises(TypeError):
            resource()
github omarryhan / aiogoogle / tests / test_units / test_GoogleAPI_Method.py View on Github external
def test__len__returns_int(open_discovery_document, name, version):
    discovery_document = open_discovery_document(name, version)
    api = GoogleAPI(discovery_document=discovery_document)
    for resource_name, _ in discovery_document.get("resources").items():
        resource = getattr(api, resource_name)
        for method_name in resource.methods_available:
            method = resource._get_method(method_name)
            assert isinstance(len(method), int)
github omarryhan / aiogoogle / tests / test_units / test_GoogleAPI_Method.py View on Github external
def test_stack_parameters_are_passed_correctly(open_discovery_document, name, version):
    discovery_document = open_discovery_document(name, version)
    api = GoogleAPI(discovery_document=discovery_document)
    for resource_name, _ in discovery_document.get("resources").items():
        resource = getattr(api, resource_name)
        for method_name in resource.methods_available:
            method = resource._get_method(method_name)
            for stack_param_name in STACK_QUERY_PARAMETERS:
                assert stack_param_name in method.optional_parameters
                assert stack_param_name in method.parameters
github omarryhan / aiogoogle / aiogoogle / auth / managers.py View on Github external
def __init__(self, session_factory=AiohttpSession, verify=True, client_creds=None):
        self.oauth2_api = GoogleAPI(OAUTH2_V2_DISCVOCERY_DOC)
        self.openid_configs = WELLKNOWN_OPENID_CONFIGS
        self.session_factory = session_factory
        self.active_session = None
        self.verify = verify
        self.client_creds = client_creds