mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Propagate changes on tests as well
This commit is contained in:
parent
08dc22b750
commit
b464bc576c
3 changed files with 29 additions and 58 deletions
|
@ -1,15 +1,9 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from moulinette.core import init_authenticator
|
|
||||||
from yunohost.utils.error import YunohostError
|
from yunohost.utils.error import YunohostError
|
||||||
from yunohost.app import app_install, app_remove
|
from yunohost.app import app_install, app_remove
|
||||||
from yunohost.domain import _get_maindomain, domain_url_available, _normalize_domain_path
|
from yunohost.domain import _get_maindomain, domain_url_available, _normalize_domain_path
|
||||||
|
|
||||||
# Instantiate LDAP Authenticator
|
|
||||||
auth_identifier = ('ldap', 'ldap-anonymous')
|
|
||||||
auth_parameters = {'uri': 'ldap://localhost:389', 'base_dn': 'dc=yunohost,dc=org'}
|
|
||||||
auth = init_authenticator(auth_identifier, auth_parameters)
|
|
||||||
|
|
||||||
|
|
||||||
# Get main domain
|
# Get main domain
|
||||||
maindomain = _get_maindomain()
|
maindomain = _get_maindomain()
|
||||||
|
@ -18,7 +12,7 @@ maindomain = _get_maindomain()
|
||||||
def setup_function(function):
|
def setup_function(function):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
app_remove(auth, "register_url_app")
|
app_remove("register_url_app")
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -26,7 +20,7 @@ def setup_function(function):
|
||||||
def teardown_function(function):
|
def teardown_function(function):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
app_remove(auth, "register_url_app")
|
app_remove("register_url_app")
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -41,28 +35,28 @@ def test_normalize_domain_path():
|
||||||
def test_urlavailable():
|
def test_urlavailable():
|
||||||
|
|
||||||
# Except the maindomain/macnuggets to be available
|
# Except the maindomain/macnuggets to be available
|
||||||
assert domain_url_available(auth, maindomain, "/macnuggets")
|
assert domain_url_available(maindomain, "/macnuggets")
|
||||||
|
|
||||||
# We don't know the domain yolo.swag
|
# We don't know the domain yolo.swag
|
||||||
with pytest.raises(YunohostError):
|
with pytest.raises(YunohostError):
|
||||||
assert domain_url_available(auth, "yolo.swag", "/macnuggets")
|
assert domain_url_available("yolo.swag", "/macnuggets")
|
||||||
|
|
||||||
|
|
||||||
def test_registerurl():
|
def test_registerurl():
|
||||||
|
|
||||||
app_install(auth, "./tests/apps/register_url_app_ynh",
|
app_install("./tests/apps/register_url_app_ynh",
|
||||||
args="domain=%s&path=%s" % (maindomain, "/urlregisterapp"), force=True)
|
args="domain=%s&path=%s" % (maindomain, "/urlregisterapp"), force=True)
|
||||||
|
|
||||||
assert not domain_url_available(auth, maindomain, "/urlregisterapp")
|
assert not domain_url_available(maindomain, "/urlregisterapp")
|
||||||
|
|
||||||
# Try installing at same location
|
# Try installing at same location
|
||||||
with pytest.raises(YunohostError):
|
with pytest.raises(YunohostError):
|
||||||
app_install(auth, "./tests/apps/register_url_app_ynh",
|
app_install("./tests/apps/register_url_app_ynh",
|
||||||
args="domain=%s&path=%s" % (maindomain, "/urlregisterapp"), force=True)
|
args="domain=%s&path=%s" % (maindomain, "/urlregisterapp"), force=True)
|
||||||
|
|
||||||
|
|
||||||
def test_registerurl_baddomain():
|
def test_registerurl_baddomain():
|
||||||
|
|
||||||
with pytest.raises(YunohostError):
|
with pytest.raises(YunohostError):
|
||||||
app_install(auth, "./tests/apps/register_url_app_ynh",
|
app_install("./tests/apps/register_url_app_ynh",
|
||||||
args="domain=%s&path=%s" % ("yolo.swag", "/urlregisterapp"), force=True)
|
args="domain=%s&path=%s" % ("yolo.swag", "/urlregisterapp"), force=True)
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
import pytest
|
import pytest
|
||||||
import time
|
|
||||||
import requests
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
from mock import ANY
|
from mock import ANY
|
||||||
|
|
||||||
from moulinette import m18n
|
from moulinette import m18n
|
||||||
from moulinette.core import init_authenticator
|
|
||||||
from yunohost.app import app_install, app_remove, app_ssowatconf
|
from yunohost.app import app_install, app_remove, app_ssowatconf
|
||||||
from yunohost.app import _is_installed
|
from yunohost.app import _is_installed
|
||||||
from yunohost.backup import backup_create, backup_restore, backup_list, backup_info, backup_delete, _recursive_umount
|
from yunohost.backup import backup_create, backup_restore, backup_list, backup_info, backup_delete, _recursive_umount
|
||||||
|
@ -17,12 +14,6 @@ from yunohost.utils.error import YunohostError
|
||||||
# Get main domain
|
# Get main domain
|
||||||
maindomain = ""
|
maindomain = ""
|
||||||
|
|
||||||
# Instantiate LDAP Authenticator
|
|
||||||
AUTH_IDENTIFIER = ('ldap', 'ldap-anonymous')
|
|
||||||
AUTH_PARAMETERS = {'uri': 'ldap://localhost:389', 'base_dn': 'dc=yunohost,dc=org'}
|
|
||||||
auth = None
|
|
||||||
|
|
||||||
|
|
||||||
def setup_function(function):
|
def setup_function(function):
|
||||||
|
|
||||||
global maindomain
|
global maindomain
|
||||||
|
@ -30,9 +21,6 @@ def setup_function(function):
|
||||||
|
|
||||||
print ""
|
print ""
|
||||||
|
|
||||||
global auth
|
|
||||||
auth = init_authenticator(AUTH_IDENTIFIER, AUTH_PARAMETERS)
|
|
||||||
|
|
||||||
assert backup_test_dependencies_are_met()
|
assert backup_test_dependencies_are_met()
|
||||||
|
|
||||||
clean_tmp_backup_directory()
|
clean_tmp_backup_directory()
|
||||||
|
@ -72,10 +60,6 @@ def setup_function(function):
|
||||||
|
|
||||||
def teardown_function(function):
|
def teardown_function(function):
|
||||||
|
|
||||||
print ""
|
|
||||||
global auth
|
|
||||||
auth = init_authenticator(AUTH_IDENTIFIER, AUTH_PARAMETERS)
|
|
||||||
|
|
||||||
assert tmp_backup_directory_is_empty()
|
assert tmp_backup_directory_is_empty()
|
||||||
|
|
||||||
reset_ssowat_conf()
|
reset_ssowat_conf()
|
||||||
|
@ -146,7 +130,7 @@ def reset_ssowat_conf():
|
||||||
|
|
||||||
# Make sure we have a ssowat
|
# Make sure we have a ssowat
|
||||||
os.system("mkdir -p /etc/ssowat/")
|
os.system("mkdir -p /etc/ssowat/")
|
||||||
app_ssowatconf(auth)
|
app_ssowatconf()
|
||||||
|
|
||||||
|
|
||||||
def delete_all_backups():
|
def delete_all_backups():
|
||||||
|
@ -158,18 +142,18 @@ def delete_all_backups():
|
||||||
def uninstall_test_apps_if_needed():
|
def uninstall_test_apps_if_needed():
|
||||||
|
|
||||||
if _is_installed("backup_legacy_app"):
|
if _is_installed("backup_legacy_app"):
|
||||||
app_remove(auth, "backup_legacy_app")
|
app_remove("backup_legacy_app")
|
||||||
|
|
||||||
if _is_installed("backup_recommended_app"):
|
if _is_installed("backup_recommended_app"):
|
||||||
app_remove(auth, "backup_recommended_app")
|
app_remove("backup_recommended_app")
|
||||||
|
|
||||||
if _is_installed("wordpress"):
|
if _is_installed("wordpress"):
|
||||||
app_remove(auth, "wordpress")
|
app_remove("wordpress")
|
||||||
|
|
||||||
|
|
||||||
def install_app(app, path, additionnal_args=""):
|
def install_app(app, path, additionnal_args=""):
|
||||||
|
|
||||||
app_install(auth, "./tests/apps/%s" % app,
|
app_install("./tests/apps/%s" % app,
|
||||||
args="domain=%s&path=%s%s" % (maindomain, path,
|
args="domain=%s&path=%s%s" % (maindomain, path,
|
||||||
additionnal_args), force=True)
|
additionnal_args), force=True)
|
||||||
|
|
||||||
|
@ -249,7 +233,7 @@ def test_backup_and_restore_all_sys():
|
||||||
assert not os.path.exists("/etc/ssowat/conf.json")
|
assert not os.path.exists("/etc/ssowat/conf.json")
|
||||||
|
|
||||||
# Restore the backup
|
# Restore the backup
|
||||||
backup_restore(auth, name=archives[0], force=True,
|
backup_restore(name=archives[0], force=True,
|
||||||
system=[], apps=None)
|
system=[], apps=None)
|
||||||
|
|
||||||
# Check ssowat conf is back
|
# Check ssowat conf is back
|
||||||
|
@ -270,13 +254,13 @@ def test_restore_system_from_Ynh2p4(monkeypatch, mocker):
|
||||||
|
|
||||||
# Restore system archive from 2.4
|
# Restore system archive from 2.4
|
||||||
try:
|
try:
|
||||||
backup_restore(auth, name=backup_list()["archives"][1],
|
backup_restore(name=backup_list()["archives"][1],
|
||||||
system=[],
|
system=[],
|
||||||
apps=None,
|
apps=None,
|
||||||
force=True)
|
force=True)
|
||||||
finally:
|
finally:
|
||||||
# Restore system as it was
|
# Restore system as it was
|
||||||
backup_restore(auth, name=backup_list()["archives"][0],
|
backup_restore(name=backup_list()["archives"][0],
|
||||||
system=[],
|
system=[],
|
||||||
apps=None,
|
apps=None,
|
||||||
force=True)
|
force=True)
|
||||||
|
@ -412,7 +396,7 @@ def test_backup_with_no_compress():
|
||||||
@pytest.mark.with_wordpress_archive_from_2p4
|
@pytest.mark.with_wordpress_archive_from_2p4
|
||||||
def test_restore_app_wordpress_from_Ynh2p4():
|
def test_restore_app_wordpress_from_Ynh2p4():
|
||||||
|
|
||||||
backup_restore(auth, system=None, name=backup_list()["archives"][0],
|
backup_restore(system=None, name=backup_list()["archives"][0],
|
||||||
apps=["wordpress"])
|
apps=["wordpress"])
|
||||||
|
|
||||||
|
|
||||||
|
@ -430,7 +414,7 @@ def test_restore_app_script_failure_handling(monkeypatch, mocker):
|
||||||
assert not _is_installed("wordpress")
|
assert not _is_installed("wordpress")
|
||||||
|
|
||||||
with pytest.raises(YunohostError):
|
with pytest.raises(YunohostError):
|
||||||
backup_restore(auth, system=None, name=backup_list()["archives"][0],
|
backup_restore(system=None, name=backup_list()["archives"][0],
|
||||||
apps=["wordpress"])
|
apps=["wordpress"])
|
||||||
|
|
||||||
m18n.n.assert_any_call('restore_app_failed', app='wordpress')
|
m18n.n.assert_any_call('restore_app_failed', app='wordpress')
|
||||||
|
@ -451,7 +435,7 @@ def test_restore_app_not_enough_free_space(monkeypatch, mocker):
|
||||||
assert not _is_installed("wordpress")
|
assert not _is_installed("wordpress")
|
||||||
|
|
||||||
with pytest.raises(YunohostError):
|
with pytest.raises(YunohostError):
|
||||||
backup_restore(auth, system=None, name=backup_list()["archives"][0],
|
backup_restore(system=None, name=backup_list()["archives"][0],
|
||||||
apps=["wordpress"])
|
apps=["wordpress"])
|
||||||
|
|
||||||
m18n.n.assert_any_call('restore_not_enough_disk_space',
|
m18n.n.assert_any_call('restore_not_enough_disk_space',
|
||||||
|
@ -470,7 +454,7 @@ def test_restore_app_not_in_backup(mocker):
|
||||||
mocker.spy(m18n, "n")
|
mocker.spy(m18n, "n")
|
||||||
|
|
||||||
with pytest.raises(YunohostError):
|
with pytest.raises(YunohostError):
|
||||||
backup_restore(auth, system=None, name=backup_list()["archives"][0],
|
backup_restore(system=None, name=backup_list()["archives"][0],
|
||||||
apps=["yoloswag"])
|
apps=["yoloswag"])
|
||||||
|
|
||||||
m18n.n.assert_any_call('backup_archive_app_not_found', app="yoloswag")
|
m18n.n.assert_any_call('backup_archive_app_not_found', app="yoloswag")
|
||||||
|
@ -483,14 +467,14 @@ def test_restore_app_already_installed(mocker):
|
||||||
|
|
||||||
assert not _is_installed("wordpress")
|
assert not _is_installed("wordpress")
|
||||||
|
|
||||||
backup_restore(auth, system=None, name=backup_list()["archives"][0],
|
backup_restore(system=None, name=backup_list()["archives"][0],
|
||||||
apps=["wordpress"])
|
apps=["wordpress"])
|
||||||
|
|
||||||
assert _is_installed("wordpress")
|
assert _is_installed("wordpress")
|
||||||
|
|
||||||
mocker.spy(m18n, "n")
|
mocker.spy(m18n, "n")
|
||||||
with pytest.raises(YunohostError):
|
with pytest.raises(YunohostError):
|
||||||
backup_restore(auth, system=None, name=backup_list()["archives"][0],
|
backup_restore(system=None, name=backup_list()["archives"][0],
|
||||||
apps=["wordpress"])
|
apps=["wordpress"])
|
||||||
|
|
||||||
m18n.n.assert_any_call('restore_already_installed_app', app="wordpress")
|
m18n.n.assert_any_call('restore_already_installed_app', app="wordpress")
|
||||||
|
@ -531,11 +515,11 @@ def _test_backup_and_restore_app(app):
|
||||||
assert app in archives_info["apps"].keys()
|
assert app in archives_info["apps"].keys()
|
||||||
|
|
||||||
# Uninstall the app
|
# Uninstall the app
|
||||||
app_remove(auth, app)
|
app_remove(app)
|
||||||
assert not app_is_installed(app)
|
assert not app_is_installed(app)
|
||||||
|
|
||||||
# Restore the app
|
# Restore the app
|
||||||
backup_restore(auth, system=None, name=archives[0],
|
backup_restore(system=None, name=archives[0],
|
||||||
apps=[app])
|
apps=[app])
|
||||||
|
|
||||||
assert app_is_installed(app)
|
assert app_is_installed(app)
|
||||||
|
@ -555,7 +539,7 @@ def test_restore_archive_with_no_json(mocker):
|
||||||
|
|
||||||
mocker.spy(m18n, "n")
|
mocker.spy(m18n, "n")
|
||||||
with pytest.raises(YunohostError):
|
with pytest.raises(YunohostError):
|
||||||
backup_restore(auth, name="badbackup", force=True)
|
backup_restore(name="badbackup", force=True)
|
||||||
m18n.n.assert_any_call('backup_invalid_archive')
|
m18n.n.assert_any_call('backup_invalid_archive')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,18 +2,11 @@ import pytest
|
||||||
import time
|
import time
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from moulinette.core import init_authenticator
|
|
||||||
from yunohost.app import app_install, app_change_url, app_remove, app_map
|
from yunohost.app import app_install, app_change_url, app_remove, app_map
|
||||||
from yunohost.domain import _get_maindomain
|
from yunohost.domain import _get_maindomain
|
||||||
|
|
||||||
from yunohost.utils.error import YunohostError
|
from yunohost.utils.error import YunohostError
|
||||||
|
|
||||||
# Instantiate LDAP Authenticator
|
|
||||||
AUTH_IDENTIFIER = ('ldap', 'ldap-anonymous')
|
|
||||||
AUTH_PARAMETERS = {'uri': 'ldap://localhost:389', 'base_dn': 'dc=yunohost,dc=org'}
|
|
||||||
|
|
||||||
auth = init_authenticator(AUTH_IDENTIFIER, AUTH_PARAMETERS)
|
|
||||||
|
|
||||||
# Get main domain
|
# Get main domain
|
||||||
maindomain = _get_maindomain()
|
maindomain = _get_maindomain()
|
||||||
|
|
||||||
|
@ -23,11 +16,11 @@ def setup_function(function):
|
||||||
|
|
||||||
|
|
||||||
def teardown_function(function):
|
def teardown_function(function):
|
||||||
app_remove(auth, "change_url_app")
|
app_remove("change_url_app")
|
||||||
|
|
||||||
|
|
||||||
def install_changeurl_app(path):
|
def install_changeurl_app(path):
|
||||||
app_install(auth, "./tests/apps/change_url_app_ynh",
|
app_install("./tests/apps/change_url_app_ynh",
|
||||||
args="domain=%s&path=%s" % (maindomain, path), force=True)
|
args="domain=%s&path=%s" % (maindomain, path), force=True)
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,7 +39,7 @@ def test_appchangeurl():
|
||||||
install_changeurl_app("/changeurl")
|
install_changeurl_app("/changeurl")
|
||||||
check_changeurl_app("/changeurl")
|
check_changeurl_app("/changeurl")
|
||||||
|
|
||||||
app_change_url(auth, "change_url_app", maindomain, "/newchangeurl")
|
app_change_url("change_url_app", maindomain, "/newchangeurl")
|
||||||
|
|
||||||
# For some reason the nginx reload can take some time to propagate ...?
|
# For some reason the nginx reload can take some time to propagate ...?
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
@ -59,4 +52,4 @@ def test_appchangeurl_sameurl():
|
||||||
check_changeurl_app("/changeurl")
|
check_changeurl_app("/changeurl")
|
||||||
|
|
||||||
with pytest.raises(YunohostError):
|
with pytest.raises(YunohostError):
|
||||||
app_change_url(auth, "change_url_app", maindomain, "changeurl")
|
app_change_url("change_url_app", maindomain, "changeurl")
|
||||||
|
|
Loading…
Add table
Reference in a new issue