diff options
author | Steven Hardy <shardy@redhat.com> | 2015-01-14 11:47:27 +0000 |
---|---|---|
committer | Steven Hardy <shardy@redhat.com> | 2015-01-15 15:41:02 +0000 |
commit | e9791d7db9bae2a19367ec69c8b0083c6aa089a4 (patch) | |
tree | a760d97900f896eca9d077a54e98a7f3fdc10e47 | |
parent | 1a550ce62bc22ba7436bd8d156b492bffce9edb5 (diff) |
test_cli add stderr/stdout sanity assertions
Currently no check for error output on stderr is made, and no
sanity checked performed on the stdout string - both yaml and json
versions could be empty and the test would still pass.
So add sanity assertions for each case so the test is a bit more
robust.
Change-Id: Iced683ff3365e0766d345a2ce840b69b501fbb54
-rw-r--r-- | os_net_config/tests/test_cli.py | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/os_net_config/tests/test_cli.py b/os_net_config/tests/test_cli.py index 6308df8..d3de720 100644 --- a/os_net_config/tests/test_cli.py +++ b/os_net_config/tests/test_cli.py @@ -49,33 +49,66 @@ class TestCli(base.TestCase): def test_bond_noop_output(self): bond_yaml = os.path.join(SAMPLE_BASE, 'bond.yaml') bond_json = os.path.join(SAMPLE_BASE, 'bond.json') - stdout_yaml, stderr = self.run_cli('ARG0 -d --provider=ifcfg --noop ' + stdout_yaml, stderr = self.run_cli('ARG0 --provider=ifcfg --noop ' '-c %s' % bond_yaml) - stdout_json, stderr = self.run_cli('ARG0 -d --provider=ifcfg --noop ' + self.assertEqual('', stderr) + stdout_json, stderr = self.run_cli('ARG0 --provider=ifcfg --noop ' '-c %s' % bond_json) + self.assertEqual('', stderr) + sanity_devices = ['DEVICE=br-ctlplane', + 'DEVICE=em2', + 'DEVICE=em1', + 'DEVICE=bond1', + 'DEVICETYPE=ovs'] + for dev in sanity_devices: + self.assertIn(dev, stdout_yaml) self.assertEqual(stdout_yaml, stdout_json) def test_bridge_noop_output(self): bridge_yaml = os.path.join(SAMPLE_BASE, 'bridge_dhcp.yaml') bridge_json = os.path.join(SAMPLE_BASE, 'bridge_dhcp.json') - stdout_yaml, stderr = self.run_cli('ARG0 -d --noop -c %s' % + stdout_yaml, stderr = self.run_cli('ARG0 --provider=eni --noop -c %s' % bridge_yaml) - stdout_json, stderr = self.run_cli('ARG0 -d --noop -c %s' % + self.assertEqual('', stderr) + stdout_json, stderr = self.run_cli('ARG0 --provider=eni --noop -c %s' % bridge_json) + self.assertEqual('', stderr) + sanity_devices = ['iface br-ctlplane inet dhcp', + 'iface em1', + 'ovs_type OVSBridge'] + for dev in sanity_devices: + self.assertIn(dev, stdout_yaml) self.assertEqual(stdout_yaml, stdout_json) def test_vlan_noop_output(self): vlan_yaml = os.path.join(SAMPLE_BASE, 'bridge_vlan.yaml') vlan_json = os.path.join(SAMPLE_BASE, 'bridge_vlan.json') - stdout_yaml, stderr = self.run_cli('ARG0 -d --noop -c %s' % vlan_yaml) - stdout_json, stderr = self.run_cli('ARG0 -d --noop -c %s' % vlan_json) + stdout_yaml, stderr = self.run_cli('ARG0 --provider=ifcfg --noop -c %s' + % vlan_yaml) + self.assertEqual('', stderr) + stdout_json, stderr = self.run_cli('ARG0 --provider=ifcfg --noop -c %s' + % vlan_json) + self.assertEqual('', stderr) + sanity_devices = ['DEVICE=br-ctlplane', + 'DEVICE=em1', + 'DEVICE=vlan16', + 'DEVICETYPE=ovs'] + for dev in sanity_devices: + self.assertIn(dev, stdout_yaml) self.assertEqual(stdout_yaml, stdout_json) def test_interface_noop_output(self): interface_yaml = os.path.join(SAMPLE_BASE, 'interface.yaml') interface_json = os.path.join(SAMPLE_BASE, 'interface.json') - stdout_yaml, stderr = self.run_cli('ARG0 -d --noop -c %s' + stdout_yaml, stderr = self.run_cli('ARG0 --provider=ifcfg --noop -c %s' % interface_yaml) - stdout_json, stderr = self.run_cli('ARG0 -d --noop -c %s' + self.assertEqual('', stderr) + stdout_json, stderr = self.run_cli('ARG0 --provider=ifcfg --noop -c %s' % interface_json) + self.assertEqual('', stderr) + sanity_devices = ['DEVICE=em1', + 'BOOTPROTO=static', + 'IPADDR=192.0.2.1'] + for dev in sanity_devices: + self.assertIn(dev, stdout_yaml) self.assertEqual(stdout_yaml, stdout_json) |