mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Added some tests for subscribing and unsubscribing
This commit is contained in:
parent
02103c07a3
commit
f015767f50
1 changed files with 18 additions and 2 deletions
|
@ -1,7 +1,9 @@
|
|||
import pytest
|
||||
import os
|
||||
import random
|
||||
|
||||
from moulinette.core import MoulinetteError
|
||||
from yunohost.utils.dns import is_yunohost_dyndns_domain
|
||||
|
||||
from yunohost.utils.error import YunohostError, YunohostValidationError
|
||||
from yunohost.domain import (
|
||||
|
@ -16,6 +18,8 @@ from yunohost.domain import (
|
|||
)
|
||||
|
||||
TEST_DOMAINS = ["example.tld", "sub.example.tld", "other-example.com"]
|
||||
TEST_DYNDNS_DOMAIN = "".join(chr(random.randint(ord("a"),ord("z"))) for x in range(15))+random.choice([".noho.st",".ynh.fr",".nohost.me"])
|
||||
TEST_DYNDNS_PASSWORD = "astrongandcomplicatedpassphrasethatisverysecure"
|
||||
|
||||
|
||||
def setup_function(function):
|
||||
|
@ -35,9 +39,9 @@ def setup_function(function):
|
|||
|
||||
# Clear other domains
|
||||
for domain in domains:
|
||||
if domain not in TEST_DOMAINS or domain == TEST_DOMAINS[2]:
|
||||
if (domain not in TEST_DOMAINS or domain == TEST_DOMAINS[2]) and domain != TEST_DYNDNS_DOMAIN:
|
||||
# Clean domains not used for testing
|
||||
domain_remove(domain)
|
||||
domain_remove(domain,no_unsubscribe=is_yunohost_dyndns_domain(domain))
|
||||
elif domain in TEST_DOMAINS:
|
||||
# Reset settings if any
|
||||
os.system(f"rm -rf {DOMAIN_SETTINGS_DIR}/{domain}.yml")
|
||||
|
@ -67,6 +71,12 @@ def test_domain_add():
|
|||
assert TEST_DOMAINS[2] in domain_list()["domains"]
|
||||
|
||||
|
||||
def test_domain_add_subscribe():
|
||||
assert TEST_DYNDNS_DOMAIN not in domain_list()["domains"]
|
||||
domain_add(TEST_DYNDNS_DOMAIN,subscribe=TEST_DYNDNS_PASSWORD)
|
||||
assert TEST_DYNDNS_DOMAIN in domain_list()["domains"]
|
||||
|
||||
|
||||
def test_domain_add_existing_domain():
|
||||
with pytest.raises(MoulinetteError):
|
||||
assert TEST_DOMAINS[1] in domain_list()["domains"]
|
||||
|
@ -79,6 +89,12 @@ def test_domain_remove():
|
|||
assert TEST_DOMAINS[1] not in domain_list()["domains"]
|
||||
|
||||
|
||||
def test_domain_remove_unsubscribe():
|
||||
assert TEST_DYNDNS_DOMAIN in domain_list()["domains"]
|
||||
domain_remove(TEST_DYNDNS_DOMAIN,unsubscribe=TEST_DYNDNS_PASSWORD)
|
||||
assert TEST_DYNDNS_DOMAIN not in domain_list()["domains"]
|
||||
|
||||
|
||||
def test_main_domain():
|
||||
current_main_domain = _get_maindomain()
|
||||
assert domain_main_domain()["current_main_domain"] == current_main_domain
|
||||
|
|
Loading…
Add table
Reference in a new issue