def get_conn(self): conn = self.get_connection(self.kylin_conn_id) if self.dsn: return kylinpy.create_kylin(self.dsn) else: self.project = self.project if self.project else conn.schema return kylinpy.Kylin(conn.host, username=conn.login, password=conn.password, port=conn.port, project=self.project, **conn.extra_dejson)
def test_service(self): cluster = create_kylin( 'kylin://*****:*****@example.com:9000/foobar?prefix=/aaa/bbb') assert isinstance(cluster.service, SERVICES['v1']) assert cluster.service.client.request_headers.get('Accept') is None assert cluster.service.client.request_headers.get( 'Authorization') == 'Basic Zm9vOmJhcg==' assert cluster.service.project == 'foobar' assert cluster.version == 'v1' cluster.username = '******' cluster.password = '******' cluster.host = 'eager_host.com' cluster.port = 1234 cluster.scheme = 'https' cluster.timeout = 1000 cluster.unverified = False cluster.prefix = '/hello/world' cluster.is_debug = True eager_client = cluster.service.client assert eager_client.host == 'https://eager_host.com:1234' assert eager_client.prefix == '/hello/world' assert eager_client.unverified is False assert eager_client.timeout == 1000 assert eager_client.is_debug is True assert cluster.service.client.request_headers.get( 'Authorization') == 'Basic eW9uZ2ppZTp6aGFv' cluster2 = create_kylin('kylin://*****:*****@example.com:9000/?version=v2') assert cluster2.version == 'v2' assert cluster2.service.client.request_headers.get( 'Accept') == 'application/vnd.apache.kylin-v2+json' assert isinstance(cluster2.service, SERVICES['v2']) cluster4 = create_kylin('kylin://*****:*****@example.com:9000/?version=v4') assert cluster4.version == 'v4' assert cluster4.service.client.request_headers.get( 'Accept') == 'application/vnd.apache.kylin-v4-public+json' assert isinstance(cluster4.service, SERVICES['v4'])
def test_init(self): cluster = create_kylin( 'kylin://name@45中文:pwd12@%[email protected]:9000/foobar') assert cluster.host == 'example.com' assert cluster.port == 9000 assert cluster.username == 'name@45中文' assert cluster.password == 'pwd12@%+' assert cluster.is_ssl is None assert cluster.prefix == '/kylin/api' assert cluster.timeout == 30 assert cluster.unverified is True assert cluster.version == 'v1' assert cluster.is_pushdown is False assert cluster.is_pushdown is False assert cluster.is_debug is False assert cluster.scheme == 'http' assert cluster.project == 'foobar'
def test_get_all_tables(self, v1_api): assert self.project.get_all_tables() == [ 'KYLIN_ACCOUNT', 'KYLIN_CAL_DT', 'KYLIN_CATEGORY_GROUPINGS', 'KYLIN_COUNTRY', 'KYLIN_SALES', ] pushdown = create_kylin( 'kylin://*****:*****@example/foobar?is_pushdown=1') assert pushdown.is_pushdown is True assert pushdown.get_all_tables() == [ 'KYLIN_ACCOUNT', 'KYLIN_CAL_DT', 'KYLIN_CATEGORY_GROUPINGS', 'KYLIN_COUNTRY', 'KYLIN_SALES', 'KYLIN_STREAMING_TABLE', ]
def project(self): return create_kylin('kylin://*****:*****@example/learn_kylin?version=v2')
def cluster(self): return create_kylin('kylin://*****:*****@example?version=v2')
def test_basic_auth_dump(self): cluster = create_kylin('kylin://*****:*****@example') assert cluster.basic_auth_dump('foo', 'bar') == { 'Authorization': 'Basic Zm9vOmJhcg==' }
def test_get_client(self): cluster = create_kylin('kylin://*****:*****@example') assert isinstance(cluster._get_client(), Client)
def project(self): return create_kylin('kylin://*****:*****@example/foobar')
def cluster(self): return create_kylin('kylin://*****:*****@example')
def project(self): return create_kylin('kylin://*****:*****@example/ssb?version=v4')