def test_dvs_agent_no_binding_mode(self):
     mock_dvs_instance = mock.MagicMock()
     import_mock = mock.patch('importlib.import_module',
                              return_value=mock_dvs_instance)
     import_patch = import_mock.start()
     cfg.CONF.set_override('agent_mode', 'dvs_no_binding', 'OPFLEX')
     with mock.patch('sys.argv'):
         gbp_ovs_agent.main()
         import_patch.assert_called_once()
         mock_dvs_instance.create_agent_config_map.assert_called_once()
     import_mock.stop()
 def test_dvs_agent_mode_no_package(self):
     import_mock = mock.patch('importlib.import_module',
                              side_effect=ValueError)
     import_patch = import_mock.start()
     cfg.CONF.set_override('agent_mode', 'dvs', 'OPFLEX')
     with mock.patch('sys.argv'), mock.patch('sys.exit') as sys_patch:
         try:
             gbp_ovs_agent.main()
         except AttributeError:
             sys_patch.assert_called_once()
         import_patch.assert_called_once()
     import_mock.stop()
Пример #3
0
 def test_dvs_agent_mode(self):
     mock_dvs_instance = mock.MagicMock()
     import_mock = mock.patch('importlib.import_module',
                              return_value=mock_dvs_instance)
     import_patch = import_mock.start()
     cfg.CONF.set_override('agent_mode', 'dvs', 'OPFLEX')
     with mock.patch('sys.argv'):
         gbp_ovs_agent.main()
         self.assertEqual(1, import_patch.call_count)
         self.assertEqual(
             1, mock_dvs_instance.create_agent_config_map.call_count)
     import_mock.stop()
 def test_opflex_agent_mode(self):
     opflex_agent = mock.patch('opflexagent.gbp_ovs_agent.GBPOpflexAgent')
     opflex_patch = opflex_agent.start()
     metadata_mgr = mock.patch(
         'opflexagent.as_metadata_manager.AsMetadataManager')
     metadata_patch = metadata_mgr.start()
     cfg.CONF.set_override('agent_mode', 'opflex', 'OPFLEX')
     with mock.patch('sys.argv'):
         gbp_ovs_agent.main()
         opflex_patch.assert_called_once()
         metadata_patch.assert_called_once()
     opflex_agent.stop()
     metadata_mgr.stop()