File tree Expand file tree Collapse file tree 3 files changed +31
-2
lines changed Expand file tree Collapse file tree 3 files changed +31
-2
lines changed Original file line number Diff line number Diff line change 1111"""
1212
1313import re
14-
14+ from pprint import pprint
1515from .rshell import CalledProcessError , shell , log_progress
1616
1717
1818def perform_initial_checks (mail_domain , pre_command = "" ):
1919 """Collecting initial DNS settings."""
2020 assert mail_domain
21+ pprint ("rdns.perform_initial_checks: " + shell .__module__ )
22+
2123 if not shell ("dig" , fail_ok = True , print = log_progress ):
2224 shell ("apt-get update && apt-get install -y dnsutils" , print = log_progress )
2325 A = query_dns ("A" , mail_domain )
Original file line number Diff line number Diff line change 11import sys
2-
2+ from pprint import pprint
33from subprocess import DEVNULL , CalledProcessError , check_output
44
55
@@ -9,6 +9,7 @@ def log_progress(data):
99
1010
1111def shell (command , fail_ok = False , print = print ):
12+ pprint ("test_cmdeploy: " + shell .__module__ )
1213 print (f"$ { command } " )
1314 args = dict (shell = True )
1415 if fail_ok :
Original file line number Diff line number Diff line change 55
66from cmdeploy .cmdeploy import get_parser , main
77from cmdeploy .www import get_paths
8+ import cmdeploy .remote .rshell
9+ import cmdeploy .dns
810
911
1012@pytest .fixture (autouse = True )
@@ -59,3 +61,27 @@ def test_www_folder(example_config, tmp_path):
5961 assert www_path == tmp_path
6062 assert src_dir == src_path
6163 assert build_dir == tmp_path .joinpath ("build" )
64+
65+
66+ def test_dns_when_ssh_docker (monkeypatch ):
67+ commands = []
68+
69+ def shell (command , fail_ok = None , print = None ):
70+ assert command == False
71+ commands .append (command )
72+
73+ # mock shell function to add called commands to a global list
74+ monkeypatch .setattr (
75+ cmdeploy .remote .rshell , shell .__name__ , shell
76+ ) # still doesn't get called in get_initial_remote_data :(
77+ print ("test_cmdeploy: " + shell .__module__ )
78+ # run cmdeploy dns with --ssh-host
79+ # @docker
80+ cmdeploy .dns .get_initial_remote_data ("@docker" , "chatmail.example.org" )
81+ for cmd in commands :
82+ print (cmd )
83+ # localhost
84+ # @local
85+ # without --ssh-host
86+ # check which commands were called
87+ assert False
You can’t perform that action at this time.
0 commit comments