-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest_sanity.py
More file actions
106 lines (79 loc) · 3.21 KB
/
test_sanity.py
File metadata and controls
106 lines (79 loc) · 3.21 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
from pathlib import Path
from polywrap_client_config_builder import PolywrapClientConfigBuilder
from polywrap_core import Uri, UriPackage
from polywrap_client import PolywrapClient
from polywrap_sys_config_bundle import sys_bundle
def test_http_plugin():
config = PolywrapClientConfigBuilder().add_bundle(sys_bundle).build()
client = PolywrapClient(config)
response = client.invoke(
uri=Uri.from_str("wrapscan.io/polywrap/http@1.0"),
method="get",
args={"url": "https://www.google.com"},
)
assert response["status"] == 200
assert response["body"] is not None
def test_logger_plugin():
config = PolywrapClientConfigBuilder().add_bundle(sys_bundle).build()
client = PolywrapClient(config)
response = client.invoke(
uri=Uri.from_str("wrapscan.io/polywrap/logger@1.0"),
method="log",
args={"level": 1, "message": "Hello Polywrap!"},
)
assert response is True
def test_file_system_resolver():
config = PolywrapClientConfigBuilder().add_bundle(sys_bundle).build()
client = PolywrapClient(config)
path_to_resolve = str(Path(__file__).parent.parent / "polywrap_sys_config_bundle" / "embeds" / "http-resolver")
response = client.invoke(
uri=Uri.from_str("wrapscan.io/polywrap/file-system-uri-resolver@1.0"),
method="tryResolveUri",
args={"authority": "fs", "path": path_to_resolve},
)
assert response["manifest"]
uri_package = client.try_resolve_uri(
uri=Uri.from_str(f"wrap://fs/{path_to_resolve}")
)
assert uri_package
assert isinstance(uri_package, UriPackage)
def test_http_resolver():
config = PolywrapClientConfigBuilder().add_bundle(sys_bundle).build()
client = PolywrapClient(config)
http_path = "wraps.wrapscan.io/r/polywrap/wrapscan-uri-resolver@1.0"
response = client.invoke(
uri=Uri.from_str("wrapscan.io/polywrap/http-uri-resolver@1.0"),
method="tryResolveUri",
args={"authority": "https", "path": http_path},
)
assert response["uri"]
assert Uri.from_str(response["uri"]).authority == "ipfs"
uri_package = client.try_resolve_uri(
uri=Uri.from_str(f"wrap://https/{http_path}")
)
assert uri_package
assert isinstance(uri_package, UriPackage)
def test_ipfs_resolver():
config = PolywrapClientConfigBuilder().add_bundle(sys_bundle).build()
client = PolywrapClient(config)
result = client.try_resolve_uri(
uri=Uri.from_str("wrap://ipfs/QmfRCVA1MSAjUbrXXjya4xA9QHkbWeiKRsT7Um1cvrR7FY")
)
assert result is not None
assert isinstance(result, UriPackage)
def test_can_resolve_wrapscan_resolver():
config = PolywrapClientConfigBuilder().add_bundle(sys_bundle).build()
client = PolywrapClient(config)
response = client.try_resolve_uri(
Uri("wrapscan.io", "polywrap/wrapscan-uri-resolver@1.0"),
)
assert response
assert isinstance(response, UriPackage)
def test_wrapscan_resolver():
config = PolywrapClientConfigBuilder().add_bundle(sys_bundle).build()
client = PolywrapClient(config)
response = client.try_resolve_uri(
Uri("wrapscan.io", "polywrap/uri-resolver@1.0"),
)
assert response
assert isinstance(response, UriPackage)