Ejemplo n.º 1
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)
Ejemplo n.º 2
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)))

        with self.assertRaises(ServiceResourceNotFoundError) as cm:
            get_legend(ctx, 'demo', 'conc_chl',
                       RequestParamsMock(cbar='sun-shine'))
        self.assertEqual('color bar sun-shine not found', cm.exception.reason)

        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)