Skip to content

Commit

Permalink
Merge pull request #48 from Erik-Lamers1/fix-purge
Browse files Browse the repository at this point in the history
Fix destroy action with --purge option
  • Loading branch information
Erik-Lamers1 authored Oct 22, 2022
2 parents 94ddb3b + ded91b1 commit 3bbb816
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 5 deletions.
54 changes: 49 additions & 5 deletions vnet_manager/tests/test_vnet_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,31 +51,61 @@ def test_main_returns_non_zero_exit_code_when_no_root_user_detected(self):
def test_main_calls_action_manager(self):
main(default_args)
self.action_manager.assert_called_once_with(
base_image=False, config_path="config", no_hosts=False, sniffer=False, provider=None, pcap_dir=settings.VNET_SNIFFER_PCAP_DIR
base_image=False,
config_path="config",
no_hosts=False,
sniffer=False,
purge=False,
provider=None,
pcap_dir=settings.VNET_SNIFFER_PCAP_DIR,
)

def test_main_calls_action_manager_with_base_image(self):
main(["destroy", "--base-image"])
self.action_manager.assert_called_once_with(
base_image=True, config_path=None, no_hosts=False, sniffer=False, provider=None, pcap_dir=settings.VNET_SNIFFER_PCAP_DIR
base_image=True,
config_path=None,
no_hosts=False,
sniffer=False,
purge=False,
provider=None,
pcap_dir=settings.VNET_SNIFFER_PCAP_DIR,
)

def test_main_calls_action_manager_with_no_hosts(self):
main(["create", "config", "--no-hosts"])
self.action_manager.assert_called_once_with(
base_image=False, config_path="config", no_hosts=True, sniffer=False, provider=None, pcap_dir=settings.VNET_SNIFFER_PCAP_DIR
base_image=False,
config_path="config",
no_hosts=True,
sniffer=False,
purge=False,
provider=None,
pcap_dir=settings.VNET_SNIFFER_PCAP_DIR,
)

def test_main_calls_action_manager_with_sniffer(self):
main(["start", "config", "--sniffer"])
self.action_manager.assert_called_once_with(
base_image=False, config_path="config", no_hosts=False, sniffer=True, provider=None, pcap_dir=settings.VNET_SNIFFER_PCAP_DIR
base_image=False,
config_path="config",
no_hosts=False,
sniffer=True,
purge=False,
provider=None,
pcap_dir=settings.VNET_SNIFFER_PCAP_DIR,
)

def test_main_calls_action_manager_with_default_provider_on_connect(self):
main(["connect", "machine1"])
self.action_manager.assert_called_once_with(
base_image=False, config_path="machine1", no_hosts=False, sniffer=False, provider="lxc", pcap_dir=settings.VNET_SNIFFER_PCAP_DIR
base_image=False,
config_path="machine1",
no_hosts=False,
sniffer=False,
purge=False,
provider="lxc",
pcap_dir=settings.VNET_SNIFFER_PCAP_DIR,
)

def test_main_calls_action_manager_with_provider(self):
Expand All @@ -85,6 +115,7 @@ def test_main_calls_action_manager_with_provider(self):
config_path="machine1",
no_hosts=False,
sniffer=False,
purge=False,
provider="test",
pcap_dir=settings.VNET_SNIFFER_PCAP_DIR,
)
Expand All @@ -101,3 +132,16 @@ def test_main_returns_action_manager_execute_return_value(self):
def test_main_executes_status_action_with_show_call(self):
main(["status", "config"])
self.manager.execute.assert_called_once_with("show")

def test_main_calls_vnet_manager_with_purge(self):
main(["destroy", "--purge"])
self.action_manager.assert_called_once_with(
base_image=False,
config_path=None,
no_hosts=False,
sniffer=False,
purge=True,
provider=None,
pcap_dir=settings.VNET_SNIFFER_PCAP_DIR,
)
self.manager.execute.assert_called_once_with("destroy")
1 change: 1 addition & 0 deletions vnet_manager/vnet_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def main(args: Sequence = None) -> int:
sniffer=args.get("sniffer", False),
base_image=args.get("base_image", False),
no_hosts=args.get("no_hosts", False),
purge=args.get("purge", False),
provider=args.get("provider"),
pcap_dir=args.get("pcap_dir", settings.VNET_SNIFFER_PCAP_DIR),
)
Expand Down

0 comments on commit 3bbb816

Please sign in to comment.