Beispiel #1
0
    def test_create_corpus_path(self):
        """Tests if the calls to CreateCorpusPath return the expected corpus path."""

        adapter = ResourceAdapter()
        path = adapter.create_corpus_path('{}/extensions/pbi.extension.cdm.json'.format(self._ROOT))
        self.assertEqual('/extensions/pbi.extension.cdm.json', path)

        path = adapter.create_corpus_path('{}/primitives.cdm.json'.format(self._ROOT))
        self.assertEqual('/primitives.cdm.json', path)
Beispiel #2
0
    async def test_read_async(self):
        """Tests if the files from the resource adapter can be read correctly."""

        adapter = ResourceAdapter()

        self.assertIsNotNone(await adapter.read_async('/extensions/pbi.extension.cdm.json'))
        self.assertIsNotNone(await adapter.read_async('/primitives.cdm.json'))
Beispiel #3
0
    def unmount(self, namespace: str) -> None:
        """unregisters a storage adapter and its root folder"""

        self._namespace_adapters.pop(namespace, None)
        self._namespace_folders.pop(namespace, None)

        if namespace in self._system_defined_namespaces:
            self._system_defined_namespaces.remove(namespace)

        # The special case, use Resource adapter.
        if (namespace == 'cdm'):
            self.mount(namespace, ResourceAdapter())
Beispiel #4
0
    def unmount(self, namespace: str) -> None:
        """unregisters a storage adapter and its root folder"""
        if not namespace:
            logger.error(self._TAG, self._ctx, 'The namespace cannot be null or empty.', StorageManager.unmount.__name__)
            return None

        if namespace in self._namespace_adapters:
            self._namespace_adapters.pop(namespace, None)
            self._namespace_folders.pop(namespace, None)
            if namespace in self._system_defined_namespaces:
                self._system_defined_namespaces.remove(namespace)

            # The special case, use Resource adapter.
            if (namespace == 'cdm'):
                self.mount(namespace, ResourceAdapter())
        else:
            logger.warning(self._TAG, self._ctx, 'Cannot remove the adapter from non-existing namespace.', StorageManager.mount.__name__)
    def test_create_adapter_path(self):
        """Tests if the calls to CreateAdapterPath return the expected adapter path."""

        adapter = ResourceAdapter()

        path = adapter.create_adapter_path('/ODI-analogs/ODIEntity.cdm.json')
        self.assertEqual('{}/ODI-analogs/ODIEntity.cdm.json'.format(self._ROOT), path)

        path = adapter.create_adapter_path('/ODI-analogs/customer/Opportunity.cdm.json')
        self.assertEqual('{}/ODI-analogs/customer/Opportunity.cdm.json'.format(self._ROOT), path)

        path = adapter.create_adapter_path('/extensions/pbi.extension.cdm.json')
        self.assertEqual('{}/extensions/pbi.extension.cdm.json'.format(self._ROOT), path)

        path = adapter.create_adapter_path('/primitives.cdm.json')
        self.assertEqual('{}/primitives.cdm.json'.format(self._ROOT), path)
    def test_create_corpus_path(self):
        """Tests if the calls to CreateCorpusPath return the expected corpus path."""

        adapter = ResourceAdapter()

        path = adapter.create_corpus_path('{}/ODI-analogs/ODIEntity.cdm.json'.format(self._ROOT))
        self.assertEqual('/ODI-analogs/ODIEntity.cdm.json', path)

        path = adapter.create_corpus_path('{}/ODI-analogs/customer/Opportunity.cdm.json'.format(self._ROOT))
        self.assertEqual('/ODI-analogs/customer/Opportunity.cdm.json', path)

        path = adapter.create_corpus_path('{}/extensions/pbi.extension.cdm.json'.format(self._ROOT))
        self.assertEqual('/extensions/pbi.extension.cdm.json', path)

        path = adapter.create_corpus_path('{}/primitives.cdm.json'.format(self._ROOT))
        self.assertEqual('/primitives.cdm.json', path)

        path = adapter.create_corpus_path('{}/ODI-analogs/customer/_allImports.cdm.json'.format(self._ROOT))
        self.assertEqual('/ODI-analogs/customer/_allImports.cdm.json', path)

        # Case where the corpus adapter path is not meant to be understood by this adapter.
        path = adapter.create_corpus_path("C:/ODI-analogs/customer/_allImports.cdm.json")
        self.assertIsNone(path)
Beispiel #7
0
    def unmount(self, namespace: str) -> None:
        """unregisters a storage adapter and its root folder"""
        with logger._enter_scope(self._TAG, self._ctx, self.unmount.__name__):
            if not namespace:
                logger.error(self._ctx, self._TAG,
                             StorageManager.unmount.__name__, None,
                             CdmLogCode.ERR_STORAGE_NULL_NAMESPACE)
                return None

            if namespace in self.namespace_adapters:
                self.namespace_adapters.pop(namespace, None)
                self._namespace_folders.pop(namespace, None)
                if namespace in self._system_defined_namespaces:
                    self._system_defined_namespaces.remove(namespace)

                # The special case, use Resource adapter.
                if (namespace == 'cdm'):
                    self.mount(namespace, ResourceAdapter())
            else:
                logger.warning(self._ctx, self._TAG,
                               StorageManager.unmount.__name__, None,
                               CdmLogCode.WARN_STORAGE_REMOVE_ADAPTER_FAILED)