Ejemplo n.º 1
0
 def __init__(self, credentials: Optional[str] = None):
     """Instantiate an XYZ object, optionally with access credentials."""
     if credentials:
         os.environ["XYZ_TOKEN"] = str(credentials)
         self.hub_api = HubApi(credentials=credentials)
     else:
         self.hub_api = HubApi()
     self.spaces = Space(api=self.hub_api)
Ejemplo n.º 2
0
def empty_space(api):
    """Create shared empty XYZ space as a pytest fixture."""
    # setup, create temporary space
    space = Space(api=api).new(
        title="Testing xyzspaces",
        description="Temporary empty space containing no features.",
    )

    sleep(0.5)
    yield space

    # now teardown (delete temporary space)
    space.delete()
Ejemplo n.º 3
0
    def __init__(self, config: Optional[XYZConfig] = None):
        """Instantiate an XYZ object, optionally with custom configuration for
           your credentials and base URL.

        :param config: An object of `class:XYZConfig`, If not provied
            ``XYZ_TOKEN`` will be used from environment variable and other
            configurations will be used as defined in module :py:mod:`default_config`
        """
        if config:
            self.hub_api = HubApi(config)
        else:
            config = XYZConfig.from_default()
            self.hub_api = HubApi(config)

        self.spaces = Space(api=self.hub_api)
Ejemplo n.º 4
0
    def __init__(self,
                 credentials: Optional[str] = None,
                 server: str = XYZ_BASE_URL):
        """Instantiate an XYZ object, optionally with access credentials
         and custom base URL.

        :param credentials: A string to serve as authentication
            (a bearer token). Will be looked up in environment variable
            ``XYZ_TOKEN`` if not provided.
        :param server: A string as base URL for Data Hub APIs. Required
            only if Data Hub APIs are self-hosted. For self-hosted Data
            Hub instances ``credentials`` is not required.
        """
        if credentials:
            os.environ["XYZ_TOKEN"] = str(credentials)
            self.hub_api = HubApi(credentials=credentials, server=server)
        else:
            self.hub_api = HubApi(server=server)
        self.spaces = Space(api=self.hub_api, server=server)
Ejemplo n.º 5
0
def test__gen_id_from_properties_exception():
    """Test exception is raised when feature has no properties."""
    space = Space()
    with pytest.raises(Exception):
        space._gen_id_from_properties(feature={}, id_properties=[])