def test_get_connection_exception(self): self.mock.StubOutWithMock(libvirt_conn, 'get_connection') libvirt_conn.get_connection(True).AndReturn(None) # running all the mocks self.mock.ReplayAll() try: connection.get_connection('QEMU', True) except SystemExit, e: self.assertEquals(type(e), type(SystemExit())) self.assertEquals(e.code, 1)
def test_get_connection_exception(self): self.mock.StubOutWithMock(libvirt_conn, "get_connection") libvirt_conn.get_connection(True).AndReturn(None) # running all the mocks self.mock.ReplayAll() try: connection.get_connection("QEMU", True) except SystemExit, e: self.assertEquals(type(e), type(SystemExit())) self.assertEquals(e.code, 1)
def test_get_connection(self): conn = libvirt_conn.LibvirtConnection(True) conn1 = None self.mock.StubOutWithMock(libvirt_conn, 'get_connection') libvirt_conn.get_connection(True).AndReturn(conn) libvirt_conn.get_connection(False).AndReturn(conn1) # running all the mocks self.mock.ReplayAll() # performing assert operations self.assertTrue(connection.get_connection('QEMU', True)) self.assertTrue(connection.get_connection('fake', True)) self.assertRaises(Exception, connection.get_connection, 'xyz', True) # Unsetting all the mocks self.mock.UnsetStubs()
def test_get_connection(self): conn = libvirt_conn.LibvirtConnection(True) conn1 = None self.mock.StubOutWithMock(libvirt_conn, "get_connection") libvirt_conn.get_connection(True).AndReturn(conn) libvirt_conn.get_connection(False).AndReturn(conn1) # running all the mocks self.mock.ReplayAll() # performing assert operations self.assertTrue(connection.get_connection("QEMU", True)) self.assertTrue(connection.get_connection("fake", True)) self.assertRaises(Exception, connection.get_connection, "xyz", True) # Unsetting all the mocks self.mock.UnsetStubs()