コード例 #1
0
    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'))
コード例 #2
0
    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)
コード例 #3
0
 def api_kwargs(self) -> Dict:
     # Overridden to NOT specify 'server_url'!
     return dict(config_store=MemConfigStore())
コード例 #4
0
ファイル: helpers.py プロジェクト: eocdb/ocdb-client
 def api_kwargs(self) -> Dict:
     return dict(config_store=MemConfigStore(server_url=TEST_URL))
コード例 #5
0
 def test_mem_config_store(self):
     self._test_config_store(MemConfigStore())
コード例 #6
0
ファイル: helpers.py プロジェクト: bcdev/ocdb-client
 def api_kwargs(self) -> Dict:
     return dict(config_store=MemConfigStore(
         server_url="https://ocdb.eumetsat.int/"))