diff --git a/drc_cmis/webservice/request.py b/drc_cmis/webservice/request.py index db3a045..35571dd 100644 --- a/drc_cmis/webservice/request.py +++ b/drc_cmis/webservice/request.py @@ -71,10 +71,14 @@ def base_url(self): @property def main_repo_id(self) -> str: """Get ID of the CMS main repository""" + return self.get_main_repo_id() - if self._main_repo_id is None: - configured_main_repo_id = self.config.main_repo_id + def get_main_repo_id(self, cache: bool = True) -> str: + configured_main_repo_id = self.config.main_repo_id + if configured_main_repo_id and cache: + return configured_main_repo_id + if self._main_repo_id is None: # Retrieving the IDs of all repositories in the CMS soap_envelope = make_soap_envelope( auth=(self.user, self.password), cmis_action="getRepositories" diff --git a/tests/test_clients.py b/tests/test_clients.py index 18d5760..5e7895b 100644 --- a/tests/test_clients.py +++ b/tests/test_clients.py @@ -46,22 +46,6 @@ def test_set_main_repo_id_if_not_set_in_settings(self): # In alfresco the repo ID is a UUID uuid.UUID(main_repo_id) - def test_that_main_repo_id_is_checked(self): - config = CMISConfig.objects.get() - config.main_repo_id = "some-rubbish-id" - config.save() - - self.cmis_client._main_repo_id = None - - with self.assertRaises(CmisRepositoryDoesNotExist): - try: - self.cmis_client.main_repo_id - except Exception as e: - # Needed or the test clean-up fails! - config.main_repo_id = "" - config.save() - raise e - def test_setting_correct_repo_id(self): # Finding what the main repo id is self.cmis_client._main_repo_id = None