コード例 #1
0
ファイル: base_tests.py プロジェクト: thomasdacosta/superset
    def __init__(self, *args, **kwargs):
        if (self.requires_examples and not os.environ.get('SOLO_TEST')
                and not os.environ.get('examples_loaded')):
            cli.load_examples(load_test_data=True)
            utils.init(superset)
            os.environ['examples_loaded'] = '1'
        super(SupersetTestCase, self).__init__(*args, **kwargs)
        self.client = app.test_client()
        self.maxDiff = None
        utils.init(superset)

        admin = appbuilder.sm.find_user('admin')
        if not admin:
            appbuilder.sm.add_user('admin',
                                   'admin',
                                   ' user',
                                   '*****@*****.**',
                                   appbuilder.sm.find_role('Admin'),
                                   password='******')

        gamma = appbuilder.sm.find_user('gamma')
        if not gamma:
            appbuilder.sm.add_user('gamma',
                                   'gamma',
                                   'user',
                                   '*****@*****.**',
                                   appbuilder.sm.find_role('Gamma'),
                                   password='******')

        alpha = appbuilder.sm.find_user('alpha')
        if not alpha:
            appbuilder.sm.add_user('alpha',
                                   'alpha',
                                   'user',
                                   '*****@*****.**',
                                   appbuilder.sm.find_role('Alpha'),
                                   password='******')

        # create druid cluster and druid datasources
        session = db.session
        cluster = session.query(
            models.DruidCluster).filter_by(cluster_name="druid_test").first()
        if not cluster:
            cluster = models.DruidCluster(cluster_name="druid_test")
            session.add(cluster)
            session.commit()

            druid_datasource1 = models.DruidDatasource(
                datasource_name='druid_ds_1', cluster_name='druid_test')
            session.add(druid_datasource1)
            druid_datasource2 = models.DruidDatasource(
                datasource_name='druid_ds_2', cluster_name='druid_test')
            session.add(druid_datasource2)
            session.commit()

        utils.init(superset)
コード例 #2
0
 def create_druid_datasource(self,
                             name,
                             id=0,
                             cols_names=[],
                             metric_names=[]):
     params = {'remote_id': id, 'database_name': 'druid_test'}
     datasource = models.DruidDatasource(id=id,
                                         datasource_name=name,
                                         cluster_name='druid_test',
                                         params=json.dumps(params))
     for col_name in cols_names:
         datasource.columns.append(models.DruidColumn(column_name=col_name))
     for metric_name in metric_names:
         datasource.metrics.append(
             models.DruidMetric(metric_name=metric_name))
     return datasource
コード例 #3
0
ファイル: base_tests.py プロジェクト: zouwen/superset
    def __init__(self, *args, **kwargs):
        if (self.requires_examples and not os.environ.get('SOLO_TEST')
                and not os.environ.get('examples_loaded')):
            logging.info("Loading examples")
            cli.load_examples(load_test_data=True)
            logging.info("Done loading examples")
            sync_role_definitions()
            os.environ['examples_loaded'] = '1'
        else:
            sync_role_definitions()
        super(SupersetTestCase, self).__init__(*args, **kwargs)
        self.client = app.test_client()
        self.maxDiff = None

        gamma_sqllab = sm.add_role("gamma_sqllab")
        for perm in sm.find_role('Gamma').permissions:
            sm.add_permission_role(gamma_sqllab, perm)
        for perm in sm.find_role('sql_lab').permissions:
            sm.add_permission_role(gamma_sqllab, perm)

        admin = appbuilder.sm.find_user('admin')
        if not admin:
            appbuilder.sm.add_user('admin',
                                   'admin',
                                   ' user',
                                   '*****@*****.**',
                                   appbuilder.sm.find_role('Admin'),
                                   password='******')

        gamma = appbuilder.sm.find_user('gamma')
        if not gamma:
            appbuilder.sm.add_user('gamma',
                                   'gamma',
                                   'user',
                                   '*****@*****.**',
                                   appbuilder.sm.find_role('Gamma'),
                                   password='******')

        gamma_sqllab = appbuilder.sm.find_user('gamma_sqllab')
        if not gamma_sqllab:
            gamma_sqllab = appbuilder.sm.add_user(
                'gamma_sqllab',
                'gamma_sqllab',
                'user',
                '*****@*****.**',
                appbuilder.sm.find_role('gamma_sqllab'),
                password='******')

        alpha = appbuilder.sm.find_user('alpha')
        if not alpha:
            appbuilder.sm.add_user('alpha',
                                   'alpha',
                                   'user',
                                   '*****@*****.**',
                                   appbuilder.sm.find_role('Alpha'),
                                   password='******')

        # create druid cluster and druid datasources
        session = db.session
        cluster = session.query(
            models.DruidCluster).filter_by(cluster_name="druid_test").first()
        if not cluster:
            cluster = models.DruidCluster(cluster_name="druid_test")
            session.add(cluster)
            session.commit()

            druid_datasource1 = models.DruidDatasource(
                datasource_name='druid_ds_1', cluster_name='druid_test')
            session.add(druid_datasource1)
            druid_datasource2 = models.DruidDatasource(
                datasource_name='druid_ds_2', cluster_name='druid_test')
            session.add(druid_datasource2)
            session.commit()