예제 #1
0
 def test_get_running_config(
         self, MockedPersistentConfig, MockedRunningConfig,
         MockedSystemConfig, MockedSystemState, MockedConfigurator):
     MockedRunningConfig.return_value.get.return_value = {}
     iface = interface.Interface()
     running_config = iface.get_running_config()
     assert {} == running_config
예제 #2
0
 def test_get_system_state(
         self, MockedPersistentConfig, MockedRunningConfig,
         MockedSystemConfig, MockedSystemState, MockedConfigurator):
     MockedSystemState.return_value.get.return_value = {}
     iface = interface.Interface()
     system_state = iface.get_system_state()
     assert {} == system_state
예제 #3
0
 def test_set_running_config(
         self, MockedPersistentConfig, MockedRunningConfig,
         MockedSystemConfig, MockedSystemState, MockedConfigurator):
     iface = interface.Interface()
     iface.set_running_config(self.REQUEST_CONFIG, self.PARAMETERS)
     MockedConfigurator.return_value.run.assert_called_with(
         self.REQUEST_CONFIG, self.PARAMETERS)
     MockedRunningConfig.return_value.set.assert_called_with(
         self.REQUEST_CONFIG)
예제 #4
0
 def test_set_running_config_is_synchronous(
         self, MockedPersistentConfig, MockedRunningConfig,
         MockedSystemConfig, MockedSystemState, MockedConfigurator):
     SLEEP = 0.1
     MockedConfigurator.return_value.run.side_effect = \
         lambda *args, **kwargs: sleep(SLEEP)
     iface = interface.Interface()
     thread_a = Thread(target=iface.set_running_config, args=({}, {}))
     thread_b = Thread(target=iface.set_running_config, args=({}, {}))
     time_start = os.times()[4]
     thread_a.start()
     thread_b.start()
     thread_a.join()
     thread_b.join()
     time_stop = os.times()[4]
     assert time_stop - time_start > 1.9 * SLEEP
예제 #5
0
 def test_set_persistent_config(
         self, MockedPersistentConfig, MockedRunningConfig,
         MockedSystemConfig, MockedSystemState, MockedConfigurator):
     iface = interface.Interface()
     iface.set_persistent_config({})
     MockedPersistentConfig.return_value.set.assert_called_with({})