mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Adapt tests for domain/path normalize
This commit is contained in:
parent
d4c3a6975e
commit
68d849f7ab
2 changed files with 19 additions and 17 deletions
|
@ -4,7 +4,7 @@ import os
|
|||
from .conftest import get_test_apps_dir
|
||||
|
||||
from yunohost.utils.error import YunohostError
|
||||
from yunohost.app import app_install, app_remove, _normalize_domain_path
|
||||
from yunohost.app import app_install, app_remove
|
||||
from yunohost.domain import _get_maindomain, domain_url_available
|
||||
from yunohost.permission import _validate_and_sanitize_permission_url
|
||||
|
||||
|
@ -28,22 +28,6 @@ def teardown_function(function):
|
|||
pass
|
||||
|
||||
|
||||
def test_normalize_domain_path():
|
||||
|
||||
assert _normalize_domain_path("https://yolo.swag/", "macnuggets") == (
|
||||
"yolo.swag",
|
||||
"/macnuggets",
|
||||
)
|
||||
assert _normalize_domain_path("http://yolo.swag", "/macnuggets/") == (
|
||||
"yolo.swag",
|
||||
"/macnuggets",
|
||||
)
|
||||
assert _normalize_domain_path("yolo.swag/", "macnuggets/") == (
|
||||
"yolo.swag",
|
||||
"/macnuggets",
|
||||
)
|
||||
|
||||
|
||||
def test_urlavailable():
|
||||
|
||||
# Except the maindomain/macnuggets to be available
|
||||
|
|
|
@ -12,6 +12,8 @@ from yunohost import domain, user
|
|||
from yunohost.utils.config import (
|
||||
ask_questions_and_parse_answers,
|
||||
PasswordQuestion,
|
||||
DomainQuestion,
|
||||
PathQuestion
|
||||
)
|
||||
from yunohost.utils.error import YunohostError
|
||||
|
||||
|
@ -1834,3 +1836,19 @@ def test_question_display_text():
|
|||
):
|
||||
ask_questions_and_parse_answers(questions, answers)
|
||||
assert "foobar" in stdout.getvalue()
|
||||
|
||||
|
||||
def test_normalize_domain():
|
||||
|
||||
assert DomainQuestion("https://yolo.swag/") == "yolo.swag"
|
||||
assert DomainQuestion("http://yolo.swag") == "yolo.swag"
|
||||
assert DomainQuestion("yolo.swag/") == "yolo.swag"
|
||||
|
||||
|
||||
def test_normalize_path():
|
||||
|
||||
assert PathQuestion("macnuggets") == "/macnuggets"
|
||||
assert PathQuestion("mac/nuggets") == "/mac/nuggets"
|
||||
assert PathQuestion("/macnuggets/") == "/macnuggets"
|
||||
assert PathQuestion("macnuggets/") == "/macnuggets"
|
||||
assert PathQuestion("////macnuggets///") == "/macnuggets"
|
||||
|
|
Loading…
Add table
Reference in a new issue