Ejemplo n.º 1
0
 def test_update_lease(self):
     with mock.patch('quantum.agent.dhcp_agent.DhcpPluginApi') as plug:
         dhcp = dhcp_agent.DhcpAgent(HOSTNAME)
         dhcp.update_lease('net_id', '192.168.1.1', 120)
         plug.assert_has_calls(
             [mock.call().update_lease_expiration(
                 'net_id', '192.168.1.1', 120)])
Ejemplo n.º 2
0
    def test_update_lease_failure(self):
        with mock.patch('quantum.agent.dhcp_agent.DhcpPluginApi') as plug:
            plug.return_value.update_lease_expiration.side_effect = Exception

            with mock.patch.object(dhcp_agent.LOG, 'exception') as log:
                dhcp = dhcp_agent.DhcpAgent(HOSTNAME)
                dhcp.update_lease('net_id', '192.168.1.1', 120)
                plug.assert_has_calls(
                    [mock.call().update_lease_expiration(
                        'net_id', '192.168.1.1', 120)])

                self.assertTrue(log.called)
                self.assertTrue(dhcp.needs_resync)