Exemplo n.º 1
0
    def test_filter_druid_datasource(self):
        gamma_ds = DruidDatasource(
            datasource_name="datasource_for_gamma",
        )
        db.session.add(gamma_ds)
        no_gamma_ds = DruidDatasource(
            datasource_name="datasource_not_for_gamma",
        )
        db.session.add(no_gamma_ds)
        db.session.commit()
        utils.merge_perm(sm, 'datasource_access', gamma_ds.perm)
        utils.merge_perm(sm, 'datasource_access', no_gamma_ds.perm)
        db.session.commit()

        gamma_ds_permission_view = (
            db.session.query(ab_models.PermissionView)
            .join(ab_models.ViewMenu)
            .filter(ab_models.ViewMenu.name == gamma_ds.perm)
            .first()
        )
        sm.add_permission_role(sm.find_role('Gamma'), gamma_ds_permission_view)

        self.login(username='******')
        url = '/druiddatasourcemodelview/list/'
        resp = self.client.get(url, follow_redirects=True)
        assert 'datasource_for_gamma' in resp.data.decode('utf-8')
        assert 'datasource_not_for_gamma' not in resp.data.decode('utf-8')
Exemplo n.º 2
0
    def test_add_slice_redirect_to_druid(self, username='******'):
        datasource = DruidDatasource(datasource_name="datasource_name", )
        db.session.add(datasource)
        db.session.commit()

        self.login(username=username)
        url = '/slicemodelview/add'
        resp = self.client.get(url, follow_redirects=True)
        assert ("Click on a datasource link to create a Slice"
                in resp.data.decode('utf-8'))

        db.session.delete(datasource)
        db.session.commit()