Skip to content

Commit 3565bf7

Browse files
author
Ilyas Gasanov
committed
[DOP-19896] Add Clickhouse API schema
1 parent eba7648 commit 3565bf7

File tree

4 files changed

+7
-70
lines changed

4 files changed

+7
-70
lines changed

syncmaster/schemas/v1/connection_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
HIVE_TYPE = Literal["hive"]
77
ORACLE_TYPE = Literal["oracle"]
88
POSTGRES_TYPE = Literal["postgres"]
9+
CLICKHOUSE_TYPE = Literal["clickhouse"]
910
S3_TYPE = Literal["s3"]
1011
HDFS_TYPE = Literal["hdfs"]
11-
CLICKHOUSE_TYPE = Literal["clickhouse"]
1212

1313

1414
class ConnectionType(str, Enum):
1515
POSTGRES = "postgres"
1616
HIVE = "hive"
1717
ORACLE = "oracle"
18+
CLICKHOUSE = "clickhouse"
1819
S3 = "s3"
1920
HDFS = "hdfs"
20-
CLICKHOUSE = "clickhouse"

tests/test_unit/test_connections/test_create_all_connection/test_create_clickhouse_connection.py

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async def test_developer_plus_can_create_clickhouse_connection(
3232
"connection_data": {
3333
"type": "clickhouse",
3434
"host": "127.0.0.1",
35-
"port": 1521,
35+
"port": 8123,
3636
"database": "database_name",
3737
},
3838
"auth_data": {
@@ -78,66 +78,3 @@ async def test_developer_plus_can_create_clickhouse_connection(
7878
"user": decrypted["user"],
7979
},
8080
}
81-
82-
83-
async def test_developer_plus_cannot_create_connection_with_type_mismatch(
84-
client: AsyncClient,
85-
group: MockGroup,
86-
session: AsyncSession,
87-
settings: Settings,
88-
role_developer_plus: UserTestRoles,
89-
event_loop,
90-
request,
91-
):
92-
# Arrange
93-
user = group.get_member_of_role(role_developer_plus)
94-
95-
# Act
96-
result = await client.post(
97-
"v1/connections",
98-
headers={"Authorization": f"Bearer {user.token}"},
99-
json={
100-
"group_id": group.id,
101-
"name": "New connection",
102-
"description": "",
103-
"connection_data": {
104-
"type": "postgres",
105-
"host": "127.0.0.1",
106-
"port": 5432,
107-
"database_name": "postgres",
108-
},
109-
"auth_data": {
110-
"type": "clickhouse",
111-
"user": "user",
112-
"password": "secret",
113-
},
114-
},
115-
)
116-
117-
# Assert
118-
assert result.json() == {
119-
"error": {
120-
"code": "invalid_request",
121-
"message": "Invalid request",
122-
"details": [
123-
{
124-
"context": {},
125-
"input": {
126-
"group_id": group.id,
127-
"name": "New connection",
128-
"description": "",
129-
"connection_data": {
130-
"type": "postgres",
131-
"host": "127.0.0.1",
132-
"port": 5432,
133-
"database_name": "postgres",
134-
},
135-
"auth_data": {"type": "clickhouse", "user": "user", "password": "secret"},
136-
},
137-
"location": ["body"],
138-
"message": "Value error, Connection data and auth data must have same types",
139-
"code": "value_error",
140-
},
141-
],
142-
},
143-
}

tests/test_unit/test_connections/test_read_connections.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,10 @@ async def test_search_connections_with_nonexistent_query(
307307
@pytest.mark.parametrize(
308308
"filter_params, expected_total",
309309
[
310-
({}, 5), # No filters applied, expecting all connections
310+
({}, 6), # No filters applied, expecting all connections
311311
({"type": ["oracle"]}, 1),
312312
({"type": ["postgres", "hive"]}, 2),
313-
({"type": ["postgres", "hive", "oracle", "hdfs", "s3"]}, 5),
313+
({"type": ["postgres", "hive", "oracle", "clickhouse", "hdfs", "s3"]}, 6),
314314
],
315315
ids=[
316316
"no_filters",

tests/test_unit/test_transfers/test_create_transfer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,12 +370,12 @@ async def test_superuser_can_create_transfer(
370370
"location": ["body", "source_params"],
371371
"message": (
372372
"Input tag 'new some connection type' found using 'type' "
373-
"does not match any of the expected tags: 'postgres', 'hdfs', 'hive', 'oracle', 's3'"
373+
"does not match any of the expected tags: 'postgres', 'hdfs', 'hive', 'oracle', 'clickhouse', 's3'"
374374
),
375375
"code": "union_tag_invalid",
376376
"context": {
377377
"discriminator": "'type'",
378-
"expected_tags": "'postgres', 'hdfs', 'hive', 'oracle', 's3'",
378+
"expected_tags": "'postgres', 'hdfs', 'hive', 'oracle', 'clickhouse', 's3'",
379379
"tag": "new some connection type",
380380
},
381381
"input": {

0 commit comments

Comments
 (0)