Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def stamp_api_version():

setup(
name="science-synapse",
version="2.8.3",
version="2.8.4",
description="Client library and CLI for the Synapse API",
author="Science Team",
author_email="team@science.xyz",
Expand Down
3 changes: 2 additions & 1 deletion synapse/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def setup_device_uri(args):
if not args.uri:
# User doesn't want to use something that needs a uri
return args
if not is_valid_ip(args.uri):
# Device accepts ip:port, so only the host part decides name vs address.
if not (is_valid_ip(args.uri) or is_valid_ip(args.uri.rsplit(":", 1)[0])):
# User passed in a name
console = Console()
device_ip = find_device_by_name(args.uri, console, False, 60)
Expand Down
21 changes: 21 additions & 0 deletions synapse/tests/cli/test_uri.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import importlib.util
from argparse import Namespace
from pathlib import Path

import synapse.cli

# conftest.py stubs synapse.cli.__main__, so load the real file under another name.
_spec = importlib.util.spec_from_file_location(
"synapse_cli_main_for_test", Path(synapse.cli.__file__).with_name("__main__.py")
)
cli_main = importlib.util.module_from_spec(_spec)
_spec.loader.exec_module(cli_main)


def test_ip_with_port_skips_name_lookup(monkeypatch):
def fail(*a, **k):
raise AssertionError("name lookup should not run")

monkeypatch.setattr(cli_main, "find_device_by_name", fail)
for uri in ["127.0.0.1", "127.0.0.1:50051", "::1"]:
assert cli_main.setup_device_uri(Namespace(uri=uri)).uri == uri
Loading