|
14 | 14 | from cloudquery.sdk.types.uuid import UUIDType |
15 | 15 |
|
16 | 16 | test_table = Table( |
17 | | - "test", |
18 | | - [ |
19 | | - Column("id", pa.int64()), |
20 | | - Column("name", pa.string()), |
21 | | - Column("json", JSONType()), |
22 | | - Column("uuid", UUIDType()), |
23 | | - ], |
24 | | -) |
25 | | - |
| 17 | + "test_table", |
| 18 | + [Column("id", pa.int64()), Column("name", pa.string()), Column("json", JSONType()), Column("uuid", UUIDType())], |
| 19 | + ) |
26 | 20 |
|
27 | 21 | def test_plugin_serve(): |
28 | 22 | p = MemDB() |
@@ -72,17 +66,29 @@ def writer_iterator(): |
72 | 66 |
|
73 | 67 | stub.Write(writer_iterator()) |
74 | 68 |
|
75 | | - response = stub.GetTables(plugin_pb2.GetTables.Request(tables=["*"])) |
| 69 | + response = stub.GetTables(plugin_pb2.GetTables.Request(tables=["*"],skip_tables=[])) |
76 | 70 | schemas = arrow.new_schemas_from_bytes(response.tables) |
77 | | - assert len(schemas) == 4 |
| 71 | + assert len(schemas) == 3 |
78 | 72 |
|
79 | | - response = stub.Sync(plugin_pb2.Sync.Request(tables=["*"])) |
| 73 | + response = stub.Sync(plugin_pb2.Sync.Request(tables=["*"],skip_tables=[])) |
| 74 | + total_migrate_tables = 0 |
80 | 75 | total_records = 0 |
| 76 | + total_errors = 0 |
81 | 77 | for msg in response: |
82 | | - if msg.insert is not None: |
| 78 | + message_type = msg.WhichOneof("message") |
| 79 | + if message_type == "insert": |
83 | 80 | rec = arrow.new_record_from_bytes(msg.insert.record) |
| 81 | + assert rec.num_rows > 0 |
84 | 82 | total_records += 1 |
85 | | - assert total_records == 1 |
| 83 | + elif message_type == "migrate_table": |
| 84 | + total_migrate_tables += 1 |
| 85 | + elif message_type == "error": |
| 86 | + total_errors += 1 |
| 87 | + else: |
| 88 | + raise NotImplementedError(f"Unknown message type {type(msg)}") |
| 89 | + assert total_migrate_tables == 3 |
| 90 | + assert total_records == 15 |
| 91 | + assert total_errors == 0 |
86 | 92 | finally: |
87 | 93 | cmd.stop() |
88 | 94 | pool.shutdown() |
@@ -122,8 +128,7 @@ def test_plugin_read(): |
122 | 128 | ], |
123 | 129 | schema=test_table.to_arrow_schema(), |
124 | 130 | ) |
125 | | - p._db["test_1"] = sample_record_1 |
126 | | - p._db["test_2"] = sample_record_2 |
| 131 | + p._db = [sample_record_1, sample_record_2] |
127 | 132 |
|
128 | 133 | cmd = serve.PluginCommand(p) |
129 | 134 | port = random.randint(5000, 50000) |
@@ -191,7 +196,7 @@ def test_plugin_package(): |
191 | 196 | }, |
192 | 197 | { |
193 | 198 | "name": "id", |
194 | | - "type": "string", |
| 199 | + "type": "int64", |
195 | 200 | "description": "", |
196 | 201 | "incremental_key": True, |
197 | 202 | "primary_key": True, |
@@ -247,7 +252,7 @@ def test_plugin_package(): |
247 | 252 | }, |
248 | 253 | { |
249 | 254 | "name": "id", |
250 | | - "type": "string", |
| 255 | + "type": "int64", |
251 | 256 | "description": "", |
252 | 257 | "incremental_key": False, |
253 | 258 | "primary_key": False, |
|
0 commit comments