def test_set_node_state_down(self):
     self.agent.node_up = True
     fake_net_mgr = fake_manager.MockNetworkManager(self.agent)
     self.agent.net_mgr = fake_net_mgr
     self.agent.set_node_state(False)
     self.assertTrue("stop" in fake_net_mgr.methods)
     self.assertTrue(self.agent.state == constants.AGENT_STOPPED)
 def test_initialize_managers(self):
     fake_net_mgr = fake_manager.MockNetworkManager(self.agent)
     self.assertIsNone(fake_net_mgr.get_driver())
     with mock.patch.object(utils, "load_object",
                            return_value=fake_net_mgr):
         self.agent._initialize_managers()
         self.assertTrue(fake_net_mgr.get_driver())
         self.assertTrue(self.agent.state == constants.AGENT_INITIALIZED)
 def test_set_node_state_up(self, mock_load_obj):
     fake_net_mgr = fake_manager.MockNetworkManager(self.agent)
     self.assertIsNone(fake_net_mgr.get_driver())
     mock_load_obj.return_value = fake_net_mgr
     with mock.patch.object(self.LOG, 'info') as mock_log_info:
         self.agent.set_node_state(True)
         self.assertTrue(mock_log_info.called)
         self.assertTrue(fake_net_mgr.get_driver())
         self.assertTrue("start" in fake_net_mgr.methods)
         self.assertTrue(self.agent.state == constants.AGENT_RUNNING)
Exemple #4
0
 def test_set_node_state_up(self):
     fake_net_mgr = fake_manager.MockNetworkManager(self.agent)
     self.assertIsNone(fake_net_mgr.get_driver())
     with contextlib.nested(
         mock.patch.object(utils, "load_object",
                           return_value=fake_net_mgr),
         mock.patch.object(self.LOG, 'info')
     ) as (load_obj, log_info):
         self.agent.set_node_state(True)
         self.assertTrue(log_info.called)
         self.assertTrue(fake_net_mgr.get_driver())
         self.assertTrue("start" in fake_net_mgr.methods)
         self.assertTrue(self.agent.state == constants.AGENT_RUNNING)