pytest: add tests for pip and poetry installed virtual envs
Also test checkout of a git tag on installation.
This commit is contained in:
committed by
Christian Decker
parent
3879d7b9bd
commit
140e33b13a
@@ -61,8 +61,15 @@ def canned_github_server(directory):
|
||||
repo_initialization = (f'cp -r {plugins_path}/* .;'
|
||||
'git add --all;'
|
||||
'git commit -m "initial commit - autogenerated by test_reckless.py";')
|
||||
tag_and_update = ('git tag v1;'
|
||||
"sed -i 's/v1/v2/g' testplugpass/testplugpass.py;"
|
||||
'git add testplugpass/testplugpass.py;'
|
||||
'git commit -m "update to v2";'
|
||||
'git tag v2;')
|
||||
subprocess.check_output([repo_initialization], env=my_env, shell=True,
|
||||
cwd=repo_dir)
|
||||
subprocess.check_output([tag_and_update], env=my_env,
|
||||
shell=True, cwd=repo_dir)
|
||||
del my_env['HOME']
|
||||
del my_env['GIT_DIR']
|
||||
del my_env['GIT_WORK_TREE']
|
||||
@@ -191,6 +198,25 @@ def test_install(node_factory):
|
||||
assert os.path.exists(plugin_path)
|
||||
|
||||
|
||||
@unittest.skipIf(VALGRIND, "virtual environment triggers memleak detection")
|
||||
def test_poetry_install(node_factory):
|
||||
"""test search, git clone, and installation to folder."""
|
||||
n = get_reckless_node(node_factory)
|
||||
r = reckless([f"--network={NETWORK}", "-v", "install", "testplugpyproj"], dir=n.lightning_dir)
|
||||
assert r.returncode == 0
|
||||
assert 'dependencies installed successfully' in r.stdout
|
||||
assert 'plugin installed:' in r.stdout
|
||||
assert 'testplugpyproj enabled' in r.stdout
|
||||
check_stderr(r.stderr)
|
||||
plugin_path = Path(n.lightning_dir) / 'reckless/testplugpyproj'
|
||||
print(plugin_path)
|
||||
assert os.path.exists(plugin_path)
|
||||
n.start()
|
||||
print(n.rpc.testmethod())
|
||||
assert n.daemon.is_in_log(r'plugin-manager: started\([0-9].*\) /tmp/ltests-[a-z0-9_].*/test_poetry_install_1/lightning-1/reckless/testplugpyproj/testplugpyproj.py')
|
||||
assert n.rpc.testmethod() == 'I live.'
|
||||
|
||||
|
||||
@unittest.skipIf(VALGRIND, "virtual environment triggers memleak detection")
|
||||
def test_local_dir_install(node_factory):
|
||||
"""Test search and install from local directory source."""
|
||||
@@ -236,4 +262,42 @@ def test_disable_enable(node_factory):
|
||||
'active': True, 'dynamic': True}
|
||||
time.sleep(1)
|
||||
print(n.rpc.plugin_list()['plugins'])
|
||||
assert(test_plugin in n.rpc.plugin_list()['plugins'])
|
||||
assert test_plugin in n.rpc.plugin_list()['plugins']
|
||||
|
||||
|
||||
@unittest.skipIf(VALGRIND, "virtual environment triggers memleak detection")
|
||||
def test_tag_install(node_factory):
|
||||
"install a plugin from a specific commit hash or tag"
|
||||
node = get_reckless_node(node_factory)
|
||||
node.start()
|
||||
r = reckless([f"--network={NETWORK}", "-v", "install", "testPlugPass"],
|
||||
dir=node.lightning_dir)
|
||||
assert r.returncode == 0
|
||||
metadata = node.lightning_dir / "reckless/testplugpass/.metadata"
|
||||
with open(metadata, "r") as md:
|
||||
header = ''
|
||||
for line in md.readlines():
|
||||
line = line.strip()
|
||||
if header == 'requested commit':
|
||||
assert line == 'None'
|
||||
header = line
|
||||
# should install v2 (latest) without specifying
|
||||
version = node.rpc.gettestplugversion()
|
||||
assert version == 'v2'
|
||||
r = reckless([f"--network={NETWORK}", "-v", "uninstall", "testplugpass"],
|
||||
dir=node.lightning_dir)
|
||||
r = reckless([f"--network={NETWORK}", "-v", "install", "testplugpass@v1"],
|
||||
dir=node.lightning_dir)
|
||||
assert r.returncode == 0
|
||||
# v1 should now be checked out.
|
||||
version = node.rpc.gettestplugversion()
|
||||
assert version == 'v1'
|
||||
installed_path = Path(node.lightning_dir) / 'reckless/testplugpass'
|
||||
assert installed_path.is_dir()
|
||||
with open(metadata, "r") as md:
|
||||
header = ''
|
||||
for line in md.readlines():
|
||||
line = line.strip()
|
||||
if header == 'requested commit':
|
||||
assert line == 'v1'
|
||||
header = line
|
||||
|
||||
Reference in New Issue
Block a user