summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-04-08 13:38:43 +0000
committerGerrit Code Review <review@openstack.org>2015-04-08 13:38:43 +0000
commit9870f46a8cec003f35d26051a8c03a558c0e6a47 (patch)
tree1742862e54c0f5f29f54b3f86932afb5d21141e3
parenta45d4797d2246e31c482f3e1713c883d86807f02 (diff)
parente5613803e8d7993bbca1b367c728341fc4412208 (diff)
downloadironic-9870f46a8cec003f35d26051a8c03a558c0e6a47.tar.gz
Merge "tests/db: Add autospec=True to mocks"
-rw-r--r--ironic/tests/db/test_conductor.py14
-rw-r--r--ironic/tests/db/test_nodes.py10
2 files changed, 12 insertions, 12 deletions
diff --git a/ironic/tests/db/test_conductor.py b/ironic/tests/db/test_conductor.py
index d93aad120..1ff182615 100644
--- a/ironic/tests/db/test_conductor.py
+++ b/ironic/tests/db/test_conductor.py
@@ -64,7 +64,7 @@ class DbConductorTestCase(base.DbTestCase):
self.dbapi.unregister_conductor,
c.hostname)
- @mock.patch.object(timeutils, 'utcnow')
+ @mock.patch.object(timeutils, 'utcnow', autospec=True)
def test_touch_conductor(self, mock_utcnow):
test_time = datetime.datetime(2000, 1, 1, 0, 0)
mock_utcnow.return_value = test_time
@@ -110,7 +110,7 @@ class DbConductorTestCase(base.DbTestCase):
self.assertEqual('hostname2', node2.reservation)
self.assertIsNone(node3.reservation)
- @mock.patch.object(timeutils, 'utcnow')
+ @mock.patch.object(timeutils, 'utcnow', autospec=True)
def test_get_active_driver_dict_one_host_no_driver(self, mock_utcnow):
h = 'fake-host'
expected = {}
@@ -120,7 +120,7 @@ class DbConductorTestCase(base.DbTestCase):
result = self.dbapi.get_active_driver_dict()
self.assertEqual(expected, result)
- @mock.patch.object(timeutils, 'utcnow')
+ @mock.patch.object(timeutils, 'utcnow', autospec=True)
def test_get_active_driver_dict_one_host_one_driver(self, mock_utcnow):
h = 'fake-host'
d = 'fake-driver'
@@ -131,7 +131,7 @@ class DbConductorTestCase(base.DbTestCase):
result = self.dbapi.get_active_driver_dict()
self.assertEqual(expected, result)
- @mock.patch.object(timeutils, 'utcnow')
+ @mock.patch.object(timeutils, 'utcnow', autospec=True)
def test_get_active_driver_dict_one_host_many_drivers(self, mock_utcnow):
h = 'fake-host'
d1 = 'driver-one'
@@ -143,7 +143,7 @@ class DbConductorTestCase(base.DbTestCase):
result = self.dbapi.get_active_driver_dict()
self.assertEqual(expected, result)
- @mock.patch.object(timeutils, 'utcnow')
+ @mock.patch.object(timeutils, 'utcnow', autospec=True)
def test_get_active_driver_dict_many_hosts_one_driver(self, mock_utcnow):
h1 = 'host-one'
h2 = 'host-two'
@@ -156,7 +156,7 @@ class DbConductorTestCase(base.DbTestCase):
result = self.dbapi.get_active_driver_dict()
self.assertEqual(expected, result)
- @mock.patch.object(timeutils, 'utcnow')
+ @mock.patch.object(timeutils, 'utcnow', autospec=True)
def test_get_active_driver_dict_many_hosts_and_drivers(self, mock_utcnow):
h1 = 'host-one'
h2 = 'host-two'
@@ -172,7 +172,7 @@ class DbConductorTestCase(base.DbTestCase):
result = self.dbapi.get_active_driver_dict()
self.assertEqual(expected, result)
- @mock.patch.object(timeutils, 'utcnow')
+ @mock.patch.object(timeutils, 'utcnow', autospec=True)
def test_get_active_driver_dict_with_old_conductor(self, mock_utcnow):
past = datetime.datetime(2000, 1, 1, 0, 0)
present = past + datetime.timedelta(minutes=2)
diff --git a/ironic/tests/db/test_nodes.py b/ironic/tests/db/test_nodes.py
index 7e3450345..be44943b4 100644
--- a/ironic/tests/db/test_nodes.py
+++ b/ironic/tests/db/test_nodes.py
@@ -136,7 +136,7 @@ class DbNodeTestCase(base.DbTestCase):
res = self.dbapi.get_node_list(filters={'maintenance': False})
self.assertEqual([node1.id], [r.id for r in res])
- @mock.patch.object(timeutils, 'utcnow')
+ @mock.patch.object(timeutils, 'utcnow', autospec=True)
def test_get_nodeinfo_list_provision(self, mock_utcnow):
past = datetime.datetime(2000, 1, 1, 0, 0)
next = past + datetime.timedelta(minutes=8)
@@ -161,7 +161,7 @@ class DbNodeTestCase(base.DbTestCase):
states.DEPLOYWAIT})
self.assertEqual([node2.id], [r[0] for r in res])
- @mock.patch.object(timeutils, 'utcnow')
+ @mock.patch.object(timeutils, 'utcnow', autospec=True)
def test_get_nodeinfo_list_inspection(self, mock_utcnow):
past = datetime.datetime(2000, 1, 1, 0, 0)
next = past + datetime.timedelta(minutes=8)
@@ -354,7 +354,7 @@ class DbNodeTestCase(base.DbTestCase):
node2.id,
{'instance_uuid': new_i_uuid})
- @mock.patch.object(timeutils, 'utcnow')
+ @mock.patch.object(timeutils, 'utcnow', autospec=True)
def test_update_node_provision(self, mock_utcnow):
mocked_time = datetime.datetime(2000, 1, 1, 0, 0)
mock_utcnow.return_value = mocked_time
@@ -378,7 +378,7 @@ class DbNodeTestCase(base.DbTestCase):
self.assertIsNone(res['provision_updated_at'])
self.assertIsNone(res['inspection_started_at'])
- @mock.patch.object(timeutils, 'utcnow')
+ @mock.patch.object(timeutils, 'utcnow', autospec=True)
def test_update_node_inspection_started_at(self, mock_utcnow):
mocked_time = datetime.datetime(2000, 1, 1, 0, 0)
mock_utcnow.return_value = mocked_time
@@ -390,7 +390,7 @@ class DbNodeTestCase(base.DbTestCase):
timeutils.normalize_time(result))
self.assertIsNone(res['inspection_finished_at'])
- @mock.patch.object(timeutils, 'utcnow')
+ @mock.patch.object(timeutils, 'utcnow', autospec=True)
def test_update_node_inspection_finished_at(self, mock_utcnow):
mocked_time = datetime.datetime(2000, 1, 1, 0, 0)
mock_utcnow.return_value = mocked_time