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
|
||||
|
||||
from moulinette.core import init_authenticator
|
||||
from yunohost.utils.error import YunohostError
|
||||
from yunohost.app import app_install, app_remove
|
||||
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
|
||||
maindomain = _get_maindomain()
|
||||
|
@ -18,7 +12,7 @@ maindomain = _get_maindomain()
|
|||
def setup_function(function):
|
||||
|
||||
try:
|
||||
app_remove(auth, "register_url_app")
|
||||
app_remove("register_url_app")
|
||||
except:
|
||||
pass
|
||||
|
||||
|
@ -26,7 +20,7 @@ def setup_function(function):
|
|||
def teardown_function(function):
|
||||
|
||||
try:
|
||||
app_remove(auth, "register_url_app")
|
||||
app_remove("register_url_app")
|
||||
except:
|
||||
pass
|
||||
|
||||
|
@ -41,28 +35,28 @@ def test_normalize_domain_path():
|
|||
def test_urlavailable():
|
||||
|
||||
# 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
|
||||
with pytest.raises(YunohostError):
|
||||
assert domain_url_available(auth, "yolo.swag", "/macnuggets")
|
||||
assert domain_url_available("yolo.swag", "/macnuggets")
|
||||
|
||||
|
||||
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)
|
||||
|
||||
assert not domain_url_available(auth, maindomain, "/urlregisterapp")
|
||||
assert not domain_url_available(maindomain, "/urlregisterapp")
|
||||
|
||||
# Try installing at same location
|
||||
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)
|
||||
|
||||
|
||||
def test_registerurl_baddomain():
|
||||
|
||||
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)
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
import pytest
|
||||
import time
|
||||
import requests
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
from mock import ANY
|
||||
|
||||
from moulinette import m18n
|
||||
from moulinette.core import init_authenticator
|
||||
from yunohost.app import app_install, app_remove, app_ssowatconf
|
||||
from yunohost.app import _is_installed
|
||||
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
|
||||
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):
|
||||
|
||||
global maindomain
|
||||
|
@ -30,9 +21,6 @@ def setup_function(function):
|
|||
|
||||
print ""
|
||||
|
||||
global auth
|
||||
auth = init_authenticator(AUTH_IDENTIFIER, AUTH_PARAMETERS)
|
||||
|
||||
assert backup_test_dependencies_are_met()
|
||||
|
||||
clean_tmp_backup_directory()
|
||||
|
@ -72,10 +60,6 @@ def setup_function(function):
|
|||
|
||||
def teardown_function(function):
|
||||
|
||||
print ""
|
||||
global auth
|
||||
auth = init_authenticator(AUTH_IDENTIFIER, AUTH_PARAMETERS)
|
||||
|
||||
assert tmp_backup_directory_is_empty()
|
||||
|
||||
reset_ssowat_conf()
|
||||
|
@ -146,7 +130,7 @@ def reset_ssowat_conf():
|
|||
|
||||
# Make sure we have a ssowat
|
||||
os.system("mkdir -p /etc/ssowat/")
|
||||
app_ssowatconf(auth)
|
||||
app_ssowatconf()
|
||||
|
||||
|
||||
def delete_all_backups():
|
||||
|
@ -158,18 +142,18 @@ def delete_all_backups():
|
|||
def uninstall_test_apps_if_needed():
|
||||
|
||||
if _is_installed("backup_legacy_app"):
|
||||
app_remove(auth, "backup_legacy_app")
|
||||
app_remove("backup_legacy_app")
|
||||
|
||||
if _is_installed("backup_recommended_app"):
|
||||
app_remove(auth, "backup_recommended_app")
|
||||
app_remove("backup_recommended_app")
|
||||
|
||||
if _is_installed("wordpress"):
|
||||
app_remove(auth, "wordpress")
|
||||
app_remove("wordpress")
|
||||
|
||||
|
||||
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,
|
||||
additionnal_args), force=True)
|
||||
|
||||
|
@ -249,7 +233,7 @@ def test_backup_and_restore_all_sys():
|
|||
assert not os.path.exists("/etc/ssowat/conf.json")
|
||||
|
||||
# Restore the backup
|
||||
backup_restore(auth, name=archives[0], force=True,
|
||||
backup_restore(name=archives[0], force=True,
|
||||
system=[], apps=None)
|
||||
|
||||
# Check ssowat conf is back
|
||||
|
@ -270,13 +254,13 @@ def test_restore_system_from_Ynh2p4(monkeypatch, mocker):
|
|||
|
||||
# Restore system archive from 2.4
|
||||
try:
|
||||
backup_restore(auth, name=backup_list()["archives"][1],
|
||||
backup_restore(name=backup_list()["archives"][1],
|
||||
system=[],
|
||||
apps=None,
|
||||
force=True)
|
||||
finally:
|
||||
# Restore system as it was
|
||||
backup_restore(auth, name=backup_list()["archives"][0],
|
||||
backup_restore(name=backup_list()["archives"][0],
|
||||
system=[],
|
||||
apps=None,
|
||||
force=True)
|
||||
|
@ -412,7 +396,7 @@ def test_backup_with_no_compress():
|
|||
@pytest.mark.with_wordpress_archive_from_2p4
|
||||
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"])
|
||||
|
||||
|
||||
|
@ -430,7 +414,7 @@ def test_restore_app_script_failure_handling(monkeypatch, mocker):
|
|||
assert not _is_installed("wordpress")
|
||||
|
||||
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"])
|
||||
|
||||
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")
|
||||
|
||||
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"])
|
||||
|
||||
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")
|
||||
|
||||
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"])
|
||||
|
||||
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")
|
||||
|
||||
backup_restore(auth, system=None, name=backup_list()["archives"][0],
|
||||
backup_restore(system=None, name=backup_list()["archives"][0],
|
||||
apps=["wordpress"])
|
||||
|
||||
assert _is_installed("wordpress")
|
||||
|
||||
mocker.spy(m18n, "n")
|
||||
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"])
|
||||
|
||||
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()
|
||||
|
||||
# Uninstall the app
|
||||
app_remove(auth, app)
|
||||
app_remove(app)
|
||||
assert not app_is_installed(app)
|
||||
|
||||
# Restore the app
|
||||
backup_restore(auth, system=None, name=archives[0],
|
||||
backup_restore(system=None, name=archives[0],
|
||||
apps=[app])
|
||||
|
||||
assert app_is_installed(app)
|
||||
|
@ -555,7 +539,7 @@ def test_restore_archive_with_no_json(mocker):
|
|||
|
||||
mocker.spy(m18n, "n")
|
||||
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')
|
||||
|
||||
|
||||
|
|
|
@ -2,18 +2,11 @@ import pytest
|
|||
import time
|
||||
import requests
|
||||
|
||||
from moulinette.core import init_authenticator
|
||||
from yunohost.app import app_install, app_change_url, app_remove, app_map
|
||||
from yunohost.domain import _get_maindomain
|
||||
|
||||
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
|
||||
maindomain = _get_maindomain()
|
||||
|
||||
|
@ -23,11 +16,11 @@ def setup_function(function):
|
|||
|
||||
|
||||
def teardown_function(function):
|
||||
app_remove(auth, "change_url_app")
|
||||
app_remove("change_url_app")
|
||||
|
||||
|
||||
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)
|
||||
|
||||
|
||||
|
@ -46,7 +39,7 @@ def test_appchangeurl():
|
|||
install_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 ...?
|
||||
time.sleep(2)
|
||||
|
@ -59,4 +52,4 @@ def test_appchangeurl_sameurl():
|
|||
check_changeurl_app("/changeurl")
|
||||
|
||||
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