Exemplo n.º 1
0
    def __init__(self, corpus: 'CdmCorpusDefinition'):
        # the default namespace to be used when not specified.
        self.default_namespace = None  # type: Optional[str]
        self.namespace_adapters = OrderedDict(
        )  # type: Dict[str, StorageAdapterBase]

        # Internal

        self._corpus = corpus
        self._namespace_folders = OrderedDict(
        )  # type: Dict[str, CdmFolderDefinition]
        self._registered_adapter_types = {
            'cdm-standards': 'CdmStandardsAdapter',
            'local': 'LocalAdapter',
            'adls': 'ADLSAdapter',
            'remote': 'RemoteAdapter',
            'github': 'GithubAdapter'
        }

        # The namespaces that have default adapters defined by the program and not by a user.
        self._system_defined_namespaces = set()  # type: Set

        # set up default adapters.
        self.mount('local', LocalAdapter(root=os.getcwd()))
        self.mount('cdm', CdmStandardsAdapter())

        self._system_defined_namespaces.add('local')
        self._system_defined_namespaces.add('cdm')

        self._TAG = StorageManager.__name__
Exemplo n.º 2
0
 def test_create_corpus_path(self):
     """Tests if the corpus path is created correctly."""
     adapter = CdmStandardsAdapter()
     adapter_path = self.ENDPOINT + self.TEST_FILE_PATH
     corpus_path = adapter.create_corpus_path(adapter_path)
     self.assertEqual(self.TEST_FILE_PATH, corpus_path)
Exemplo n.º 3
0
 async def test_read_async(self):
     """Tests if the adapter is able to read correctly."""
     adapter = CdmStandardsAdapter()
     foundations = await adapter.read_async(self.TEST_FILE_PATH)
     self.assertIsNotNone(foundations)
Exemplo n.º 4
0
 def test_create_adapter_path(self):
     """Tests if the adapter path is created correctly."""
     adapter = CdmStandardsAdapter()
     corpus_path = self.TEST_FILE_PATH
     adapter_path = adapter.create_adapter_path(corpus_path)
     self.assertEqual(self.ENDPOINT + corpus_path, adapter_path)