コード例 #1
0
    def test_get_dataset_tile(self):
        ctx = new_test_service_context()
        tile = get_dataset_tile(ctx, 'demo', 'conc_tsm', '0', '0', '0', RequestParamsMock())
        self.assertIsInstance(tile, bytes)

        tile = get_dataset_tile(ctx, 'demo', 'conc_tsm', '-20', '0', '0', RequestParamsMock())
        self.assertIsInstance(tile, bytes)
コード例 #2
0
    def test_get_dataset_tile_with_time_dim(self):
        ctx = new_test_service_context()
        tile = get_dataset_tile(ctx, 'demo', 'conc_tsm', '0', '0', '0', RequestParamsMock(time='2017-01-26'))
        self.assertIsInstance(tile, bytes)

        ctx = new_test_service_context()
        tile = get_dataset_tile(ctx, 'demo', 'conc_tsm', '0', '0', '0', RequestParamsMock(time='2017-01-26/2017-01-27'))
        self.assertIsInstance(tile, bytes)

        ctx = new_test_service_context()
        tile = get_dataset_tile(ctx, 'demo', 'conc_tsm', '0', '0', '0', RequestParamsMock(time='current'))
        self.assertIsInstance(tile, bytes)
コード例 #3
0
ファイル: test_reqparams.py プロジェクト: sfoucher/xcube
    def test_get_query_argument(self):
        rp = RequestParamsMock()
        self.assertEqual('bert', rp.get_query_argument('s', 'bert'))
        self.assertEqual(234, rp.get_query_argument_int('i', 234))
        self.assertEqual(0.2, rp.get_query_argument_float('f', 0.2))
        self.assertEqual((-10.4, 51.8),
                         rp.get_query_argument_point('p', (-10.4, 51.8)))

        rp = RequestParamsMock(s='bibo', i='465', f='0.1', p='-10.4, 51.8')
        self.assertEqual('bibo', rp.get_query_argument('s', None))
        self.assertEqual(465, rp.get_query_argument_int('i', None))
        self.assertEqual(465., rp.get_query_argument_float('i', None))
        self.assertEqual(0.1, rp.get_query_argument_float('f', None))
        self.assertEqual((-10.4, 51.8), rp.get_query_argument_point('p', None))
コード例 #4
0
 def test_get_dataset_rgb_tile_no_vars(self):
     ctx = new_test_service_context()
     with self.assertRaises(ServiceBadRequestError) as cm:
         get_dataset_tile(ctx, 'demo', 'rgb', '0', '0', '0', RequestParamsMock())
     self.assertEqual(400, cm.exception.status_code)
     self.assertEqual("No variable in dataset 'demo' specified for RGB",
                      cm.exception.reason)
コード例 #5
0
 def test_get_dataset_rgb_tile_invalid_b(self):
     ctx = new_test_service_context('config-rgb.yml')
     with self.assertRaises(ServiceBadRequestError) as cm:
         get_dataset_tile(ctx, 'demo-rgb', 'rgb', '0', '0', '0', RequestParamsMock(b='refl_3'))
     self.assertEqual(400, cm.exception.status_code)
     self.assertEqual("Variable 'refl_3' not found in dataset 'demo-rgb'",
                      cm.exception.reason)
コード例 #6
0
 def test_get_dataset_tile_with_invalid_time_dim(self):
     ctx = new_test_service_context()
     with self.assertRaises(ServiceBadRequestError) as cm:
         get_dataset_tile(ctx, 'demo', 'conc_tsm', '0', '0', '0', RequestParamsMock(time='Gnaaark!'))
     self.assertEqual(400, cm.exception.status_code)
     self.assertEqual("'Gnaaark!' is not a valid value for dimension 'time'",
                      cm.exception.reason)
コード例 #7
0
    def test_get_legend(self):
        ctx = new_test_service_context()
        image = get_legend(ctx, 'demo', 'conc_chl', RequestParamsMock())
        self.assertEqual("<class 'bytes'>", str(type(image)))

        # This is fine, because we fall back to "viridis".
        image = get_legend(ctx, 'demo', 'conc_chl', RequestParamsMock(cbar='sun-shine'))
        self.assertEqual("<class 'bytes'>", str(type(image)))

        with self.assertRaises(ServiceBadRequestError) as cm:
            get_legend(ctx, 'demo', 'conc_chl', RequestParamsMock(vmin='sun-shine'))
        self.assertEqual("""Parameter "vmin" must be a number, but was 'sun-shine'""", cm.exception.reason)

        with self.assertRaises(ServiceBadRequestError) as cm:
            get_legend(ctx, 'demo', 'conc_chl', RequestParamsMock(width='sun-shine'))
        self.assertEqual("""Parameter "width" must be an integer, but was 'sun-shine'""", cm.exception.reason)
コード例 #8
0
ファイル: test_tiles.py プロジェクト: dcs4cop/xcube
 def test_get_dataset_tile_invalid_variable(self):
     ctx = new_test_service_context()
     with self.assertRaises(ServiceResourceNotFoundError) as cm:
         get_dataset_tile(ctx, 'demo', 'conc_tdi', '0', '0', '0',
                          RequestParamsMock())
     self.assertEqual(404, cm.exception.status_code)
     self.assertEqual('Variable "conc_tdi" not found in dataset "demo"',
                      f'{cm.exception.reason}')
コード例 #9
0
 def test_get_dataset_tile_with_all_params(self):
     ctx = new_test_service_context()
     tile = get_dataset_tile(
         ctx, 'demo', 'conc_tsm', '0', '0', '0',
         RequestParamsMock(time='current',
                           cbar='plasma',
                           vmin='0.1',
                           vmax='0.3'))
     self.assertIsInstance(tile, bytes)
コード例 #10
0
    def test_get_dataset_tile_with_time_dim(self):
        ctx = new_test_service_context()
        tile = get_dataset_tile(ctx, 'demo', 'conc_tsm', '0', '0', '0', RequestParamsMock(time='2017-01-26'))
        self.assertIsInstance(tile, bytes)

        ctx = new_test_service_context()
        tile = get_dataset_tile(ctx, 'demo', 'conc_tsm', '0', '0', '0', RequestParamsMock(time='2017-01-26/2017-01-27'))
        self.assertIsInstance(tile, bytes)

        ctx = new_test_service_context()
        tile = get_dataset_tile(ctx, 'demo', 'conc_tsm', '0', '0', '0', RequestParamsMock(time='current'))
        self.assertIsInstance(tile, bytes)

        with self.assertRaises(ServiceBadRequestError) as cm:
            get_dataset_tile(ctx, 'demo', 'conc_tsm', '0', '0', '0', RequestParamsMock(time='Gnaaark!'))
        self.assertEqual(400, cm.exception.status_code)
        self.assertEqual("'Gnaaark!' is not a valid value for "
                         "dimension 'time' of variable 'conc_tsm' of dataset 'demo'",
                         cm.exception.reason)
コード例 #11
0
 def test_get_ne2_tile(self):
     ctx = new_test_service_context()
     tile = get_ne2_tile(ctx, '0', '0', '0', RequestParamsMock())
     self.assertIsInstance(tile, bytes)
コード例 #12
0
 def test_get_dataset_rgb_tile(self):
     ctx = new_test_service_context('config-rgb.yml')
     tile = get_dataset_tile(ctx, 'demo-rgb', 'rgb', '0', '0', '0', RequestParamsMock())
     self.assertIsInstance(tile, bytes)