How to use the aiogoogle.resource.Resource 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_GoogleAPI_Resource.py View on Github external
def test_resources_available_property():
    resource = Resource(
        name="irrelevant",
        resource_specs={
            "resources": {"first_resource": 1, "second_resource": 2},
            "methods": {"third_method": 3, "forth_method": 4},
        },
        global_parameters=None,
        schemas=None,
        batch_path=None,
        root_url=None,
        validate=False,
        service_path=None,
    )
    assert "first_resource" in resource.resources_available
    assert "second_resource" in resource.resources_available
github omarryhan / aiogoogle / tests / test_units / test_GoogleAPI_Resource.py View on Github external
def test_resource_constructor(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_object = getattr(api, resource_name)
        assert isinstance(resource_object, Resource)
        assert resource_name == resource_object.name
        assert (
            resource_object._resource_specs
            == discovery_document["resources"][resource_name]
        )
        assert resource_object._global_parameters == discovery_document.get(
            "parameters"
        )
        assert resource_object._schemas == discovery_document.get("schemas")
        ##
        assert api["schemas"] is resource_object._schemas
        assert api["parameters"] is resource_object._global_parameters
github omarryhan / aiogoogle / tests / test_units / test_GoogleAPI_Resource.py View on Github external
def test_methods_available_property():
    resource = Resource(
        name="irrelevant",
        resource_specs={
            "resources": {"first_resource": 1, "second_resource": 2},
            "methods": {"third_method": 3, "forth_method": 4},
        },
        global_parameters=None,
        schemas=None,
        batch_path=None,
        root_url=None,
        validate=False,
        service_path=None,
    )
    assert "third_method" in resource.methods_available
    assert "forth_method" in resource.methods_available
github omarryhan / aiogoogle / tests / test_units / test_GoogleAPI_Resource.py View on Github external
def test_resource_len_are_counted_correctly():
    resource = Resource(
        name="irrelevant",
        resource_specs={
            "resources": {"first_resource": 1, "second_resource": 2, "basdasd": 239},
            "methods": {"third_method": 3, "forth_method": 4},
        },
        global_parameters=None,
        schemas=None,
        root_url=None,
        batch_path=None,
        validate=False,
        service_path=None,
    )
    assert len(resource) == 2
github omarryhan / aiogoogle / tests / test_units / test_GoogleAPI.py View on Github external
def test_getattr(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_object = getattr(api, resource_name)
        assert isinstance(resource_object, Resource)
        assert resource_name == resource_object.name
github omarryhan / aiogoogle / aiogoogle / resource.py View on Github external
def _get_resource(self, resource_name):
        return Resource(
            name=resource_name,
            resource_specs=self["resources"][resource_name],
            global_parameters=self["parameters"],
            schemas=self["schemas"]
            or {},  # josnschema validator will fail if schemas isn't a dict
            root_url=self["rootUrl"],
            service_path=self["servicePath"],
            batch_path=self["batchPath"],
            validate=self._validate,
        )
github omarryhan / aiogoogle / aiogoogle / resource.py View on Github external
def _get_resource(self, resource_name):
        return Resource(
            name=resource_name,
            resource_specs=self["resources"][resource_name],
            global_parameters=self._global_parameters,
            schemas=self._schemas,
            root_url=self._root_url,
            service_path=self._service_path,
            batch_path=self._batch_path,
            validate=self._validate,
        )