-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpackage.py
More file actions
88 lines (85 loc) · 3.29 KB
/
package.py
File metadata and controls
88 lines (85 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import json
import os
from cloudquery.sdk import serve
from plugin import ExamplePlugin
def test_plugin_package():
p = ExamplePlugin()
cmd = serve.PluginCommand(p)
cmd.run(["package", "-m", "test", "v0.0.1", "."])
assert os.path.isfile("dist/tables.json")
assert os.path.isfile("dist/package.json")
assert os.path.isfile("dist/docs/overview.md")
assert os.path.isfile("dist/plugin-example-v0.0.1-linux-amd64.tar")
assert os.path.isfile("dist/plugin-example-v0.0.1-linux-arm64.tar")
with open("dist/tables.json", "r") as f:
tables = json.loads(f.read())
assert tables == [
{
"name": "example_item",
"title": "Example Item",
"description": "",
"is_incremental": False,
"parent": "",
"relations": [],
"columns": [
{
"name": "num",
"type": "uint64",
"description": "",
"incremental_key": False,
"primary_key": True,
"not_null": False,
"unique": False,
},
{
"name": "string",
"type": "string",
"description": "",
"incremental_key": False,
"primary_key": False,
"not_null": False,
"unique": False,
},
{
"name": "date",
"type": "date64[ms]",
"description": "",
"incremental_key": False,
"primary_key": False,
"not_null": False,
"unique": False,
},
],
},
]
with open("dist/package.json", "r") as f:
package = json.loads(f.read())
assert package["schema_version"] == 1
assert package["name"] == "example"
assert package["version"] == "v0.0.1"
assert package["team"] == "cloudquery"
assert package["kind"] == "source"
assert package["message"] == "test"
assert package["protocols"] == [3]
assert len(package["supported_targets"]) == 2
assert package["package_type"] == "docker"
assert package["supported_targets"][0]["os"] == "linux"
assert package["supported_targets"][0]["arch"] == "amd64"
assert (
package["supported_targets"][0]["path"]
== "plugin-example-v0.0.1-linux-amd64.tar"
)
assert (
package["supported_targets"][0]["docker_image_tag"]
== "docker.cloudquery.io/cloudquery/source-example:v0.0.1-linux-amd64"
)
assert package["supported_targets"][1]["os"] == "linux"
assert package["supported_targets"][1]["arch"] == "arm64"
assert (
package["supported_targets"][1]["path"]
== "plugin-example-v0.0.1-linux-arm64.tar"
)
assert (
package["supported_targets"][1]["docker_image_tag"]
== "docker.cloudquery.io/cloudquery/source-example:v0.0.1-linux-arm64"
)