organize remotely executing functions in "cmdeploy.remote" sub package

This commit is contained in:
holger krekel
2024-08-01 19:02:41 +02:00
parent cdfce25494
commit e973bc1f41
11 changed files with 131 additions and 77 deletions

View File

@@ -1,6 +1,6 @@
import pytest
from cmdeploy import remote_funcs
from cmdeploy import remote
from cmdeploy.dns import check_full_zone, check_initial_remote_data
@@ -14,7 +14,7 @@ def mockdns_base(monkeypatch):
except KeyError:
return ""
monkeypatch.setattr(remote_funcs, query_dns.__name__, query_dns)
monkeypatch.setattr(remote.rdns, query_dns.__name__, query_dns)
return qdict
@@ -32,13 +32,13 @@ def mockdns(mockdns_base):
class TestPerformInitialChecks:
def test_perform_initial_checks_ok1(self, mockdns):
remote_data = remote_funcs.perform_initial_checks("some.domain")
remote_data = remote.rdns.perform_initial_checks("some.domain")
assert len(remote_data) == 7
@pytest.mark.parametrize("drop", ["A", "AAAA"])
def test_perform_initial_checks_with_one_of_A_AAAA(self, mockdns, drop):
del mockdns[drop]
remote_data = remote_funcs.perform_initial_checks("some.domain")
remote_data = remote.rdns.perform_initial_checks("some.domain")
assert len(remote_data) == 7
assert not remote_data[drop]
@@ -49,7 +49,7 @@ class TestPerformInitialChecks:
def test_perform_initial_checks_no_mta_sts(self, mockdns):
del mockdns["CNAME"]
remote_data = remote_funcs.perform_initial_checks("some.domain")
remote_data = remote.rdns.perform_initial_checks("some.domain")
assert len(remote_data) == 4
assert not remote_data["MTA_STS"]
@@ -85,14 +85,14 @@ class TestZonefileChecks:
def test_check_zonefile_all_ok(self, cm_data, mockdns_base):
zonefile = cm_data.get("zftest.zone")
parse_zonefile_into_dict(zonefile, mockdns_base)
required_diff, recommended_diff = remote_funcs.check_zonefile(zonefile)
required_diff, recommended_diff = remote.rdns.check_zonefile(zonefile)
assert not required_diff and not recommended_diff
def test_check_zonefile_recommended_not_set(self, cm_data, mockdns_base):
zonefile = cm_data.get("zftest.zone")
zonefile_mocked = zonefile.split("; Recommended")[0]
parse_zonefile_into_dict(zonefile_mocked, mockdns_base)
required_diff, recommended_diff = remote_funcs.check_zonefile(zonefile)
required_diff, recommended_diff = remote.rdns.check_zonefile(zonefile)
assert not required_diff
assert len(recommended_diff) == 8