Skip to content

Commit 18e98a2

Browse files
committed
[SPT-777] Added new tests: channel print-filter-recipient, print-all; service metadata-set-api, metadata-init-utility
1 parent 7886224 commit 18e98a2

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

snet/cli/test/functional_tests/func_tests.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import importlib.util
99
import math
1010
import re
11-
import time
11+
import json
1212

1313
from snet.cli.commands.commands import BlockchainCommand
1414

@@ -256,7 +256,7 @@ def setUp(self):
256256
self.group = "default_group"
257257
data = execute(["channel", "print-filter-sender"], self.parser, self.conf)
258258
lines = data.split("\n")
259-
self.max_id = ""
259+
self.max_id = "_some_text_"
260260
for line in lines:
261261
parts = line.split()
262262
if len(parts) >= 6 and parts[0].isdigit() and parts[-1].isdigit():
@@ -270,8 +270,8 @@ def test_channel_1_extend(self):
270270
result1 = execute(["channel", "extend-add", self.max_id, "--amount", self.amount, "-y"], self.parser, self.conf)
271271
else:
272272
block_number = int(execute(["channel", "block-number"], self.parser, self.conf))
273-
channel_open_output = execute(["channel", "open", self.org_id, self.group, self.amount, f"{block_number-1}", "-y"], self.parser, self.conf)
274-
self.max_id = re.search(r"#channel_id\s+(\d+)", channel_open_output)
273+
channel_open_output = execute(["channel", "open", self.org_id, self.group, self.amount, f"{block_number-1}", "-y", "--open-new-anyway"], self.parser, self.conf)
274+
self.max_id = str(re.search(r"#channel_id\s+(\d+)", channel_open_output))
275275
execute(["channel", "extend-add", self.max_id, "--amount", self.amount, "-y"], self.parser, self.conf)
276276
result1 = execute(["channel", "extend-add", self.max_id, "--amount", self.amount, "-y"], self.parser,
277277
self.conf)
@@ -292,6 +292,10 @@ def test_channel_4_print_filter_group(self):
292292
result = execute(["channel", "print-filter-group", self.org_id, self.group], self.parser, self.conf)
293293
assert self.max_id in result
294294

295+
def test_channel_5_print_filter_recipient(self):
296+
result = execute(["channel", "print-filter-recipient"], self.parser, self.conf)
297+
assert "Channels for recipient:", ADDR in result
298+
295299
def test_channel_5_claim(self):
296300
print(self.max_id)
297301
execute(["account", "deposit", self.amount, "-y", "-q"], self.parser, self.conf)
@@ -312,6 +316,9 @@ def test_channel_5_claim(self):
312316
print(result1)
313317
assert ("event: ChannelSenderClaim" in result1) and ("event: ChannelSenderClaim" in result2)
314318

319+
def test_channel_6_print_all(self):
320+
result = execute(["channel", "print-all", "-ds"], self.parser, self.conf)
321+
assert self.max_id in result
315322

316323

317324
class TestAHClient(BaseTest):
@@ -546,6 +553,7 @@ def test_62_change_service_metadata(self, mock_input):
546553
def test_63_tags(self):
547554
execute(["service", "metadata-add-tags", self.tags], self.parser, self.conf)
548555
execute(["service", "update-metadata", self.org_id, self.service_id, "-y"], self.parser, self.conf)
556+
execute(["service", "metadata-remove-tags", self.tags], self.parser, self.conf)
549557
print(execute(["service", "print-tags", self.org_id, self.service_id], self.parser, self.conf))
550558
result = execute(["service", "print-tags", self.org_id, self.service_id], self.parser, self.conf)
551559
assert self.tags in result
@@ -556,6 +564,19 @@ def test_64_get_api_metadata(self):
556564
execute(["service", "get-api-metadata", "./"], self.parser, self.conf)
557565
assert os.path.exists(f"./ExampleService.proto")
558566

567+
def test_65_metadata_set_api(self):
568+
res = execute(["service", "metadata-set-api", "./", "--storage", "ipfs"], self.parser, self.conf)
569+
print(res)
570+
with open("service_metadata.json", "r", encoding="utf-8") as f:
571+
metadata = json.load(f)
572+
assert metadata["service_api_source"].startswith("ipfs://")
573+
574+
@patch("builtins.input", side_effect=["auto_test", "1", "ipfs", "./", "y", "default_group", "1", ADDR, ADDR, "y", "150", ADDR, "n", "google.com", "long description", "short", "Stasy", "stasy@hotmail.com", "n", "y", "service_metadata"])
575+
def test_channel_66_metadata_init_utility(self, mock_input):
576+
os.remove(f"./service_metadata.json")
577+
execute(["service", "metadata-init-utility"], self.parser, self.conf)
578+
assert os.path.exists(f"./service_metadata.json")
579+
559580
def test_7_delete_service(self):
560581
result = execute(["service", "delete", self.org_id, self.service_id, "-y"], self.parser, self.conf)
561582
os.remove(f"./service_metadata.json")

0 commit comments

Comments
 (0)