Esempio n. 1
0
    def test_6_delete(self):
        for predictor_name in [TEST_PREDICTOR, TEST_PREDICTOR_CSV]:
            res = requests.delete(
                f'{HTTP_API_ROOT}/predictors/{predictor_name}')
            assert res.status_code == 200
            check_predictor_not_exists(predictor_name)

        for ds_name in [TEST_DS_CSV, TEST_DS]:
            res = requests.delete(f'{HTTP_API_ROOT}/datasources/{ds_name}')
            assert res.status_code == 200
            check_ds_not_exists(ds_name)
Esempio n. 2
0
    def test_1_wrong_integration(self):
        '''
        start mindsdb with publish integration with wrong password
        try create ds
        change password to correct
        '''
        original_db_password = config['integrations']['default_mariadb'][
            'password']
        self.mdb, datastore = run_environment(
            config,
            apis=['mysql', 'http'],
            override_integration_config={
                'default_mariadb': {
                    'publish': True,
                    'password': '******'
                }
            },
            mindsdb_database=MINDSDB_DATABASE)

        check_ds_not_exists(TEST_DS)

        # TODO creating DS from unexists integration raise not critical error in code.
        # need fix it and return human-readable error
        # related issue: https://github.com/mindsdb/mindsdb/issues/945
        # data = {
        #     "integration_id": 'unexists_integration',
        #     "name": TEST_DS,
        #     "query": f"select * from test_data.{TEST_DATASET} limit 50;"
        # }
        # res = requests.put(f'{HTTP_API_ROOT}/datasources/{TEST_DS}', json=data)
        # assert res ?

        # check create DS with wrong integration password
        data = {
            "integration_id": 'default_mariadb',
            "name": TEST_DS,
            "query": f"select * from test_data.{TEST_DATASET} limit 100;"
        }
        res = requests.put(f'{HTTP_API_ROOT}/datasources/{TEST_DS}', json=data)
        assert 'Access denied for user' in res.json()['message']

        check_ds_not_exists(TEST_DS)

        # restore password
        res = requests.post(
            f'{HTTP_API_ROOT}/config/integrations/default_mariadb',
            json={'params': {
                'password': original_db_password
            }})
        assert res.status_code == 200
        config['integrations']['default_mariadb'][
            'password'] = original_db_password
Esempio n. 3
0
    def test_1_upload_ds(self):
        check_ds_not_exists(TEST_DS_CSV)

        with open(self.external_datasource_csv_path, 'rb') as f:
            d = f.read()
        res = requests.put(f'{HTTP_API_ROOT}/datasources/{TEST_DS_CSV}',
                           files={
                               'file': ('data.csv', d, 'text/csv'),
                               'name': (None, TEST_DS_CSV),
                               'source_type': (None, 'file'),
                               'source': (None, 'data.csv')
                           })
        assert res.status_code == 200

        check_ds_exists(TEST_DS_CSV)
        check_ds_analyzable(TEST_DS_CSV)
Esempio n. 4
0
    def test_3_create_ds_from_sql_by_http(self):
        '''
        check is no DS with this name
        create DS
        analyse it
        '''
        check_ds_not_exists(TEST_DS)

        data = {
            "integration_id": TEST_INTEGRATION,
            "name": TEST_DS,
            "query": f"select * from test_data.{TEST_DATASET} limit 100;"
        }
        res = requests.put(f'{HTTP_API_ROOT}/datasources/{TEST_DS}', json=data)
        assert res.status_code == 200

        check_ds_exists(TEST_DS)
        check_ds_analyzable(TEST_DS)
Esempio n. 5
0
    def test_1_wrong_integration(self):
        '''
        start mindsdb with publish integration with wrong password
        try create ds
        change password to correct
        '''
        original_db_password = config['integrations']['default_mariadb'][
            'password']
        self.mdb, datastore = run_environment(
            config,
            apis=['mysql', 'http'],
            override_integration_config={
                'default_mariadb': {
                    'publish': True,
                    'password': '******'
                }
            },
            mindsdb_database=MINDSDB_DATABASE)

        check_ds_not_exists(TEST_DS)

        # check create DS with wrong integration password
        data = {
            "integration_id": 'default_mariadb',
            "name": TEST_DS,
            "query": f"select * from test_data.{TEST_DATASET} limit 100;"
        }
        res = requests.put(f'{HTTP_API_ROOT}/datasources/{TEST_DS}', json=data)
        assert 'Access denied for user' in res.json()['message']

        check_ds_not_exists(TEST_DS)

        # restore password
        res = requests.post(
            f'{HTTP_API_ROOT}/config/integrations/default_mariadb',
            json={'params': {
                'password': original_db_password
            }})
        assert res.status_code == 200
        config['integrations']['default_mariadb'][
            'password'] = original_db_password