test:domains: dyndns_recovery mock as api call to avoid cli prompts

This commit is contained in:
axolotle 2023-09-28 17:23:51 +02:00
parent c019f7f24a
commit 253a042314

View file

@ -1,8 +1,10 @@
import pytest
import os
import time
import random
from mock import patch
from moulinette import Moulinette
from moulinette.core import MoulinetteError
from yunohost.utils.error import YunohostError, YunohostValidationError
@ -87,6 +89,8 @@ def test_domain_add_and_remove_dyndns():
def test_domain_dyndns_recovery():
# Devs: if you get `too_many_request` errors, ask the team to add your IP to the rate limit excempt
assert TEST_DYNDNS_DOMAIN not in domain_list()["domains"]
# mocked as API call to avoid CLI prompts
with patch.object(Moulinette.interface, "type", "api"):
# add domain without recovery password
domain_add(TEST_DYNDNS_DOMAIN)
assert TEST_DYNDNS_DOMAIN in domain_list()["domains"]
@ -106,6 +110,7 @@ def test_domain_dyndns_recovery():
assert TEST_DYNDNS_DOMAIN in domain_list()["domains"]
# remove the dyndns domain
domain_remove(TEST_DYNDNS_DOMAIN, dyndns_recovery_password=TEST_DYNDNS_PASSWORD)
assert TEST_DYNDNS_DOMAIN not in domain_list()["domains"]