def test_make_url(self): api = OCDBApi(config_store=MemConfigStore()) with self.assertRaises(ValueError) as cm: api._make_url('/datasets') self.assertEqual('"server_url" is not configured', f'{cm.exception}') server_url_with_trailing_slash = 'http://localhost:2385/' api = OCDBApi(config_store=MemConfigStore( server_url=server_url_with_trailing_slash)) self.assertEqual( 'http://localhost:2385/eocdb/api/' + TEST_VERSION + '/datasets', api._make_url('datasets')) self.assertEqual( 'http://localhost:2385/eocdb/api/' + TEST_VERSION + '/datasets', api._make_url('/datasets')) server_url_without_trailing_slash = 'http://localhost:2385' api = OCDBApi(config_store=MemConfigStore( server_url=server_url_without_trailing_slash)) self.assertEqual( 'http://localhost:2385/eocdb/api/' + TEST_VERSION + '/datasets', api._make_url('datasets')) self.assertEqual( 'http://localhost:2385/eocdb/api/' + TEST_VERSION + '/datasets', api._make_url('/datasets'))
def test_constr(self): api = OCDBApi() self.assertIsNotNone(api.config) self.assertIsNotNone(api.server_url) api = OCDBApi( server_url="https://bibosrv", config_store=MemConfigStore(server_url="https://bertsrv")) self.assertIsNotNone(api.config) self.assertEqual("https://bibosrv", api.server_url)
def api_kwargs(self) -> Dict: # Overridden to NOT specify 'server_url'! return dict(config_store=MemConfigStore())
def api_kwargs(self) -> Dict: return dict(config_store=MemConfigStore(server_url=TEST_URL))
def test_mem_config_store(self): self._test_config_store(MemConfigStore())
def api_kwargs(self) -> Dict: return dict(config_store=MemConfigStore( server_url="https://ocdb.eumetsat.int/"))