]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
remove incorrect mock assert_called in unit tests
authorMark McClain <mark.mcclain@dreamhost.com>
Fri, 7 Sep 2012 18:52:12 +0000 (14:52 -0400)
committerMark McClain <mark.mcclain@dreamhost.com>
Fri, 7 Sep 2012 19:01:26 +0000 (15:01 -0400)
fixes bug 1047569

The unit tests were calling a nonexistent assert_called() on the
mocks.  This patch fixes the problem by using the correct assert for
checking that the mocked method was invoked.

Note: This patch does not fix the error in test_call_driver() because a
separate bug fix revises the test.

Change-Id: Ie62e2e64f314f9ba34761e63cd5d0d6e44c5d094

quantum/tests/unit/test_dhcp_agent.py

index fe71ec51871732fb1f94ec5cf1bb2b67b879b665..2ab84f49844300521e3964217cc74bf531096c4c 100644 (file)
@@ -338,7 +338,7 @@ class TestDhcpPluginApiProxy(unittest.TestCase):
 
     def test_get_active_networks(self):
         self.proxy.get_active_networks()
-        self.call.assert_called()
+        self.assertTrue(self.call.called)
         self.make_msg.assert_called_once_with('get_active_networks',
                                               host='foo')
 
@@ -346,7 +346,7 @@ class TestDhcpPluginApiProxy(unittest.TestCase):
         self.call.return_value = dict(a=1)
         retval = self.proxy.get_network_info('netid')
         self.assertEqual(retval.a, 1)
-        self.call.assert_called()
+        self.assertTrue(self.call.called)
         self.make_msg.assert_called_once_with('get_network_info',
                                               network_id='netid',
                                               host='foo')
@@ -355,7 +355,7 @@ class TestDhcpPluginApiProxy(unittest.TestCase):
         self.call.return_value = dict(a=1)
         retval = self.proxy.get_dhcp_port('netid', 'devid')
         self.assertEqual(retval.a, 1)
-        self.call.assert_called()
+        self.assertTrue(self.call.called)
         self.make_msg.assert_called_once_with('get_dhcp_port',
                                               network_id='netid',
                                               device_id='devid',
@@ -363,7 +363,7 @@ class TestDhcpPluginApiProxy(unittest.TestCase):
 
     def test_release_dhcp_port(self):
         self.proxy.release_dhcp_port('netid', 'devid')
-        self.call.assert_called()
+        self.assertTrue(self.call.called)
         self.make_msg.assert_called_once_with('release_dhcp_port',
                                               network_id='netid',
                                               device_id='devid',
@@ -371,7 +371,7 @@ class TestDhcpPluginApiProxy(unittest.TestCase):
 
     def test_release_port_fixed_ip(self):
         self.proxy.release_port_fixed_ip('netid', 'devid', 'subid')
-        self.call.assert_called()
+        self.assertTrue(self.call.called)
         self.make_msg.assert_called_once_with('release_port_fixed_ip',
                                               network_id='netid',
                                               subnet_id='subid',
@@ -381,7 +381,7 @@ class TestDhcpPluginApiProxy(unittest.TestCase):
     def test_update_lease_expiration(self):
         with mock.patch.object(self.proxy, 'cast') as mock_cast:
             self.proxy.update_lease_expiration('netid', 'ipaddr', 1)
-            mock_cast.assert_called()
+            self.assertTrue(mock_cast.called)
         self.make_msg.assert_called_once_with('update_lease_expiration',
                                               network_id='netid',
                                               ip_address='ipaddr',