Skip to content

Commit

Permalink
Merge "Remove mox from nova/tests/unit/virt/xenapi/test_driver.py"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Dec 14, 2016
2 parents 73f5b1f + eed029d commit 94fddf7
Showing 1 changed file with 28 additions and 25 deletions.
53 changes: 28 additions & 25 deletions nova/tests/unit/virt/xenapi/test_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,21 @@ def test_available_resource(self):
driver = self._get_driver()
driver._session.product_version = (6, 8, 2)

self.stubs.Set(driver.host_state, 'get_host_stats', self.host_stats)

resources = driver.get_available_resource(None)
self.assertEqual(6008002, resources['hypervisor_version'])
self.assertEqual(50, resources['vcpus'])
self.assertEqual(3, resources['memory_mb'])
self.assertEqual(5, resources['local_gb'])
self.assertEqual(10, resources['vcpus_used'])
self.assertEqual(3 - 2, resources['memory_mb_used'])
self.assertEqual(2, resources['local_gb_used'])
self.assertEqual('XenServer', resources['hypervisor_type'])
self.assertEqual('somename', resources['hypervisor_hostname'])
self.assertEqual(1, resources['disk_available_least'])
with mock.patch.object(driver.host_state, 'get_host_stats',
side_effect=self.host_stats) as mock_get:

resources = driver.get_available_resource(None)
self.assertEqual(6008002, resources['hypervisor_version'])
self.assertEqual(50, resources['vcpus'])
self.assertEqual(3, resources['memory_mb'])
self.assertEqual(5, resources['local_gb'])
self.assertEqual(10, resources['vcpus_used'])
self.assertEqual(3 - 2, resources['memory_mb_used'])
self.assertEqual(2, resources['local_gb_used'])
self.assertEqual('XenServer', resources['hypervisor_type'])
self.assertEqual('somename', resources['hypervisor_hostname'])
self.assertEqual(1, resources['disk_available_least'])
mock_get.assert_called_once_with(refresh=True)

def test_overhead(self):
driver = self._get_driver()
Expand All @@ -102,11 +104,10 @@ def test_overhead(self):
def test_set_bootable(self):
driver = self._get_driver()

self.mox.StubOutWithMock(driver._vmops, 'set_bootable')
driver._vmops.set_bootable('inst', True)
self.mox.ReplayAll()

driver.set_bootable('inst', True)
with mock.patch.object(driver._vmops,
'set_bootable') as mock_set_bootable:
driver.set_bootable('inst', True)
mock_set_bootable.assert_called_once_with('inst', True)

def test_post_interrupted_snapshot_cleanup(self):
driver = self._get_driver()
Expand All @@ -126,13 +127,15 @@ def test_get_volume_connector(self):
driver = self._get_driver()
self.flags(connection_url='http://%s' % ip,
connection_password='test_pass', group='xenserver')
self.stubs.Set(driver.host_state, 'get_host_stats', self.host_stats)

connector = driver.get_volume_connector({'uuid': 'fake'})
self.assertIn('ip', connector)
self.assertEqual(connector['ip'], ip)
self.assertIn('initiator', connector)
self.assertEqual(connector['initiator'], 'someiqn')
with mock.patch.object(driver.host_state, 'get_host_stats',
side_effect=self.host_stats) as mock_get:

connector = driver.get_volume_connector({'uuid': 'fake'})
self.assertIn('ip', connector)
self.assertEqual(connector['ip'], ip)
self.assertIn('initiator', connector)
self.assertEqual(connector['initiator'], 'someiqn')
mock_get.assert_called_once_with(refresh=True)

def test_get_block_storage_ip(self):
my_ip = '123.123.123.123'
Expand Down

0 comments on commit 94fddf7

Please sign in to comment.