def test_run_cmd_exec_error(self, mock_run): mock_process = mock.MagicMock() mock_process.returncode = 1 mock_run.return_value = mock_process vsctl = VSCtl(protocol='tcp', ip_addr='127.0.0.1', port=6640) vsctl.run('show')
def test_run_with_no_parse(self, mock_run): mock_popen = mock.MagicMock() mock_popen.returncode = 0 mock_run.return_value = mock_popen vsctl = VSCtl(protocol='tcp', ip_addr='127.0.0.1', port=6640) output = vsctl.run('show', parser=None) eq_(mock_popen, output)
def test_run_cmd_parse_error(self, mock_run): mock_process = mock.MagicMock() mock_process.returncode = 0 mock_run.return_value = mock_process mock_parser = mock.MagicMock( side_effect=VSCtlCmdExecError('Expected Error')) vsctl = VSCtl(protocol='tcp', ip_addr='127.0.0.1', port=6640) vsctl.run('show', parser=mock_parser)
def test_ovsdb_addr_ipv6(self): vsctl = VSCtl(protocol='tcp', ip_addr='::1', port=6640) eq_('tcp:[::1]:6640', vsctl.ovsdb_addr)
def test_ovsdb_addr_ipv4(self): vsctl = VSCtl(protocol='tcp', ip_addr='127.0.0.1', port=6640) eq_('tcp:127.0.0.1:6640', vsctl.ovsdb_addr)
def test_init_with_invalid_port(self): VSCtl(port='xxx')
def test_init_with_invalid_ip_addr(self): VSCtl(ip_addr='xxx.xxx.xxx.xxx')
def test_init_with_invalid_protocol(self): VSCtl(protocol='protocol')