diff options
author | Dan Prince <dprince@redhat.com> | 2015-08-14 17:20:47 -0400 |
---|---|---|
committer | Dan Prince <dprince@redhat.com> | 2015-08-14 17:23:19 -0400 |
commit | 7aed850aaffe8f22cc95d26ec6d48dc1fc0fd834 (patch) | |
tree | 23ecdd6ea7cd17f4e5e51e7b27bf41663c43a1a7 /os_net_config/tests | |
parent | 103b87aa82cfd298b664fe1314e987bd953ec20d (diff) |
Add --detailed-exit-codes
This patch adds a new --detailed-exit-codes option which can
be used to optionally enable the os-net-config CLI to return
exit code 2 if there have been modifications. Detailed
exit codes are useful if you need to trigger subsequent
external actions based whether os-net-config made changes or not.
Change-Id: I8f22fa15335d1276f4e444a6454a24ff486e1495
Diffstat (limited to 'os_net_config/tests')
-rw-r--r-- | os_net_config/tests/test_cli.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/os_net_config/tests/test_cli.py b/os_net_config/tests/test_cli.py index 310a527..98477fc 100644 --- a/os_net_config/tests/test_cli.py +++ b/os_net_config/tests/test_cli.py @@ -17,7 +17,9 @@ import os.path import sys +import os_net_config from os_net_config import cli +from os_net_config import impl_ifcfg from os_net_config.tests import base import six @@ -121,3 +123,26 @@ class TestCli(base.TestCase): '-c %s' % (provider, bond_yaml)) self.assertEqual('', stderr) self.assertIn('File: /rootfs/', stdout_yaml) + + def test_interface_noop_detailed_exit_codes(self): + interface_yaml = os.path.join(SAMPLE_BASE, 'interface.yaml') + stdout_yaml, stderr = self.run_cli('ARG0 --provider=ifcfg --noop ' + '-c %s --detailed-exit-codes' + % interface_yaml, exitcodes=(2,)) + + def test_interface_noop_detailed_exit_codes_no_changes(self): + interface_yaml = os.path.join(SAMPLE_BASE, 'interface.yaml') + + class TestImpl(os_net_config.NetConfig): + + def add_interface(self, interface): + pass + + def apply(self, cleanup=False, activate=True): + # this fake implementation returns no changes + return {} + + self.stubs.Set(impl_ifcfg, 'IfcfgNetConfig', TestImpl) + stdout_yaml, stderr = self.run_cli('ARG0 --provider=ifcfg --noop ' + '-c %s --detailed-exit-codes' + % interface_yaml, exitcodes=(0,)) |