Exemple #1
0
    def test_to_dict(self, high_quality_image: io.BytesIO) -> None:
        """
        It is possible to dump a database to a dictionary and load it back.
        """
        database = VuforiaDatabase()
        vws_client = VWS(
            server_access_key=database.server_access_key,
            server_secret_key=database.server_secret_key,
        )

        # We test a database with a target added.
        with MockVWS() as mock:
            mock.add_database(database=database)
            vws_client.add_target(
                name='example',
                width=1,
                image=high_quality_image,
                active_flag=True,
                application_metadata=None,
            )

        database_dict = database.to_dict()
        # The dictionary is JSON dump-able
        assert json.dumps(database_dict)

        new_database = VuforiaDatabase.from_dict(database_dict=database_dict)
        assert new_database == database
Exemple #2
0
def get_all_databases() -> Set[VuforiaDatabase]:
    """
    Get all database objects from the task manager back-end.
    """
    target_manager_base_url = os.environ['TARGET_MANAGER_BASE_URL']
    response = requests.get(url=f'{target_manager_base_url}/databases')
    return {
        VuforiaDatabase.from_dict(database_dict=database_dict)
        for database_dict in response.json()
    }