コード例 #1
0
ファイル: manager_test.py プロジェクト: strategist922/Tron
 def test_validate_fragment(self):
     autospec_method(self.manager.load)
     name = 'the_name'
     self.manager.validate_fragment(name, self.content)
     container = self.manager.load.return_value
     container.add.assert_called_with(name, self.content)
     container.validate.assert_called_with()
コード例 #2
0
ファイル: jobrun_test.py プロジェクト: ContextLogic/Tron
    def test_start_no_startable_action_runs(self):
        autospec_method(self.job_run._do_start)
        self.job_run.action_runs.has_startable_action_runs = False

        assert not self.job_run.start()
        self.job_run.event.info.assert_called_with('start')
        assert not self.job_run.event.ok.mock_calls
コード例 #3
0
ファイル: jobrun_test.py プロジェクト: ContextLogic/Tron
    def test_do_start_some_failed(self):
        returns = [True, None]
        autospec_method(self.job_run._start_action_runs, return_value=returns)

        assert self.job_run._do_start()
        assert_equal(self.job_run.event.ok.call_count, 1)
        self.job_run.event.ok.assert_called_with('started')
コード例 #4
0
ファイル: service_test.py プロジェクト: Codeacious/Tron
 def test_handle_instance_state_change_failed(self):
     autospec_method(self.service.notify)
     autospec_method(self.service.record_events)
     instance_event = serviceinstance.ServiceInstance.STATE_FAILED
     self.service._handle_instance_state_change(mock.Mock(), instance_event)
     assert not self.service.notify.mock_calls
     self.service.record_events.assert_called_with()
コード例 #5
0
ファイル: service_test.py プロジェクト: Codeacious/Tron
 def test_handle_instance_state_change_starting(self):
     autospec_method(self.service.notify)
     autospec_method(self.service.record_events)
     instance_event = serviceinstance.ServiceInstance.STATE_STARTING
     self.service._handle_instance_state_change(mock.Mock(), instance_event)
     assert not self.service.notify.mock_calls
     assert not self.service.record_events.mock_calls
コード例 #6
0
 def test_handle_action_exit_up(self):
     self.task.action = mock.create_autospec(ActionCommand)
     self.task.action.is_failed = False
     autospec_method(self.task.queue)
     self.task._handle_action_exit()
     self.task.notify.assert_called_with(self.task.NOTIFY_UP)
     self.task.queue.assert_called_with()
コード例 #7
0
 def setup_task(self):
     self.node = mock.create_autospec(node.Node)
     self.pid_filename = '/tmp/filename'
     self.task = serviceinstance.ServiceInstanceStopTask(
         'id', self.node, self.pid_filename)
     autospec_method(self.task.watch)
     autospec_method(self.task.notify)
コード例 #8
0
ファイル: controller_test.py プロジェクト: Codeacious/Tron
 def test_read_config_no_header(self):
     name = 'some_name'
     autospec_method(self.controller._get_config_content)
     autospec_method(self.controller.render_template)
     resp = self.controller.read_config(name, add_header=False)
     assert not self.controller.render_template.called
     assert_equal(resp['config'], self.controller._get_config_content.return_value)
コード例 #9
0
 def test_handle_action_unknown(self):
     self.task.action = mock.create_autospec(ActionCommand)
     self.task.action.is_unknown = True
     autospec_method(self.task.queue)
     self.task._handle_action_exit()
     self.task.notify.assert_called_with(self.task.NOTIFY_FAILED)
     assert_equal(self.task.queue.call_count, 1)
コード例 #10
0
ファイル: jobrun_test.py プロジェクト: ContextLogic/Tron
 def test_cancel_pending(self):
     pending_runs = [mock.Mock() for _ in xrange(2)]
     autospec_method(self.run_collection.get_pending,
         return_value=pending_runs)
     self.run_collection.cancel_pending()
     for pending_run in pending_runs:
         pending_run.cancel.assert_called_with()
コード例 #11
0
ファイル: jobrun_test.py プロジェクト: pombredanne/Tron
 def test_handler_not_end_state_event(self):
     autospec_method(self.job_run.finalize)
     autospec_method(self.job_run._start_action_runs)
     self.action_run.is_done = False
     self.job_run.handler(self.action_run, mock.Mock())
     assert not self.job_run.finalize.mock_calls
     assert not self.job_run._start_action_runs.mock_calls
コード例 #12
0
ファイル: mcp_test.py プロジェクト: Codeacious/Tron
 def test_load_config(self):
     autospec_method(self.mcp.apply_config)
     self.mcp.config = mock.create_autospec(manager.ConfigManager)
     self.mcp._load_config()
     self.mcp.state_watcher.disabled.assert_called_with()
     self.mcp.apply_config.assert_called_with(
         self.mcp.config.load.return_value, reconfigure=False)
コード例 #13
0
ファイル: jobrun_test.py プロジェクト: pombredanne/Tron
 def test_handler_finished_with_cleanup_done(self):
     self.job_run.action_runs.is_active = False
     self.job_run.action_runs.is_scheduled = False
     self.job_run.action_runs.cleanup_action_run = mock.Mock(is_done=True)
     autospec_method(self.job_run.finalize)
     self.job_run.handler(self.action_run, mock.Mock())
     self.job_run.finalize.assert_called_with()
コード例 #14
0
ファイル: jobrun_test.py プロジェクト: pombredanne/Tron
 def test_handler_action_run_skipped(self):
     self.action_run.is_broken = False
     self.action_run.is_skipped = True
     self.job_run.action_runs.is_scheduled = True
     autospec_method(self.job_run._start_action_runs)
     self.job_run.handler(self.action_run, mock.Mock())
     assert not self.job_run._start_action_runs.mock_calls
コード例 #15
0
ファイル: node_test.py プロジェクト: Web5design/Tron
 def test_stop(self):
     autospec_method(self.node._fail_run)
     action_command = mock.create_autospec(actioncommand.ActionCommand,
         id=mock.Mock())
     self.node.run_states[action_command.id] = mock.Mock()
     self.node.stop(action_command)
     assert_equal(self.node._fail_run.call_count, 1)
コード例 #16
0
ファイル: action_runner_test.py プロジェクト: Codeacious/Tron
 def test_write(self, mock_yaml, mock_open):
     command, proc = 'do this', mock.Mock()
     autospec_method(self.status_file.get_content)
     self.status_file.write(command, proc)
     self.status_file.get_content.assert_called_with(command, proc)
     mock_yaml.dump.assert_called_with(
         self.status_file.get_content.return_value,
         mock_open.return_value.__enter__.return_value)
コード例 #17
0
 def test_handle_action_exit_up(self):
     self.task.action = mock.create_autospec(ActionCommand)
     self.task.action.is_failed = False
     self.task.action.is_unknown = False
     autospec_method(self.task.queue)
     self.task._handle_action_exit()
     self.task.notify.assert_called_with(self.task.NOTIFY_UP)
     self.task.queue.assert_called_with()
コード例 #18
0
 def test_read_config_no_header(self):
     name = 'some_name'
     autospec_method(self.controller._get_config_content)
     autospec_method(self.controller.render_template)
     resp = self.controller.read_config(name, add_header=False)
     assert not self.controller.render_template.called
     assert_equal(resp['config'],
                  self.controller._get_config_content.return_value)
コード例 #19
0
 def test_handle_instance_state_change_down(self):
     autospec_method(self.service.notify)
     instance_event = serviceinstance.ServiceInstance.STATE_DOWN
     self.service._handle_instance_state_change(mock.Mock(), instance_event)
     self.service.notify.assert_called_with(
         self.service.NOTIFY_STATE_CHANGE,
     )
     self.service.instances.clear_down.assert_called_with()
コード例 #20
0
ファイル: actioncommand_test.py プロジェクト: wfxiang08/Tron
 def test_build_stop_action_command(self):
     id, command = 'id', 'do a thing'
     autospec_method(self.factory.build_command)
     action_command = self.factory.build_stop_action_command(id, command)
     assert_equal(action_command.id,
                  '%s.%s' % (id, self.factory.build_command.return_value))
     assert_equal(action_command.command,
                  self.factory.build_command.return_value)
コード例 #21
0
 def test_getChild(self):
     autospec_method(self.resource.get_run_from_identifier)
     identifier = 'identifier'
     resource = self.resource.getChild(identifier, None)
     assert_equal(
         resource.job_run,
         self.resource.get_run_from_identifier.return_value,
     )
コード例 #22
0
ファイル: action_runner_test.py プロジェクト: wfxiang08/Tron
 def test_write(self, mock_yaml, mock_open):
     command, proc = 'do this', mock.Mock()
     autospec_method(self.status_file.get_content)
     self.status_file.write(command, proc)
     self.status_file.get_content.assert_called_with(command, proc)
     mock_yaml.dump.assert_called_with(
         self.status_file.get_content.return_value,
         mock_open.return_value.__enter__.return_value)
コード例 #23
0
ファイル: service_test.py プロジェクト: Codeacious/Tron
 def test_restore_state(self):
     autospec_method(self.service.watch_instances)
     autospec_method(self.service.enable)
     state_data = {'enabled': True, 'instances': []}
     self.service.restore_state(state_data)
     self.service.watch_instances.assert_called_with(
         self.instances.restore_state.return_value)
     self.service.enable.assert_called_with()
コード例 #24
0
 def test_build_stop_action_command(self):
     id, command = 'id', 'do a thing'
     autospec_method(self.factory.build_command)
     action_command = self.factory.build_stop_action_command(id, command)
     assert_equal(action_command.id,
         '%s.%s' % (id, self.factory.build_command.return_value))
     assert_equal(action_command.command,
         self.factory.build_command.return_value)
コード例 #25
0
ファイル: jobrun_test.py プロジェクト: shaikhanas1993/Tron
 def test_handler_finished_with_cleanup(self):
     self.job_run.action_runs.is_active = False
     self.job_run.action_runs.is_scheduled = False
     self.job_run.action_runs.cleanup_action_run = mock.Mock(is_done=False)
     autospec_method(self.job_run.finalize)
     self.job_run.handler(self.action_run, mock.Mock())
     assert not self.job_run.finalize.mock_calls
     self.job_run.action_runs.cleanup_action_run.start.assert_called_with()
コード例 #26
0
 def test_connnectionSecure(self):
     self.transport.connection_defer = mock.Mock()
     autospec_method(self.transport.requestService)
     self.transport.connectionSecure()
     conn = self.transport.connection_defer.mock_calls[0][1][0]
     assert isinstance(conn, ssh.ClientConnection)
     auth_service = self.transport.requestService.mock_calls[0][1][0]
     assert isinstance(auth_service, ssh.NoPasswordAuthClient)
コード例 #27
0
ファイル: actionrun_test.py プロジェクト: Codeacious/Tron
 def test_is_done_true_because_blocked(self):
     self.run_map['action_name'].machine.state = ActionRun.STATE_FAILED
     self.run_map['second_name'].machine.state = ActionRun.STATE_QUEUED
     autospec_method(self.collection._is_run_blocked)
     blocked_second_action_run = lambda ar: ar == self.run_map['second_name']
     self.collection._is_run_blocked.side_effect = blocked_second_action_run
     assert self.collection.is_done
     assert self.collection.is_failed
コード例 #28
0
ファイル: service_test.py プロジェクト: wfxiang08/Tron
 def test_restore_state(self):
     autospec_method(self.service.watch_instances)
     autospec_method(self.service.enable)
     state_data = {'enabled': True, 'instances': []}
     self.service.restore_state(state_data)
     self.service.watch_instances.assert_called_with(
         self.instances.restore_state.return_value)
     self.service.enable.assert_called_with()
コード例 #29
0
ファイル: ssh_test.py プロジェクト: Codeacious/Tron
 def test_connnectionSecure(self):
     self.transport.connection_defer = mock.Mock()
     autospec_method(self.transport.requestService)
     self.transport.connectionSecure()
     conn = self.transport.connection_defer.mock_calls[0][1][0]
     assert isinstance(conn, ssh.ClientConnection)
     auth_service  = self.transport.requestService.mock_calls[0][1][0]
     assert isinstance(auth_service, ssh.NoPasswordAuthClient)
コード例 #30
0
 def test_replace(self):
     autospec_method(self.collection.add)
     item = mock.Mock()
     self.collection.replace(item)
     self.collection.add.assert_called_with(
         item,
         self.collection.remove_item,
     )
コード例 #31
0
ファイル: jobrun_test.py プロジェクト: shaikhanas1993/Tron
 def test_cancel_pending(self):
     pending_runs = [mock.Mock() for _ in range(2)]
     autospec_method(
         self.run_collection.get_pending,
         return_value=pending_runs,
     )
     self.run_collection.cancel_pending()
     for pending_run in pending_runs:
         pending_run.cancel.assert_called_with()
コード例 #32
0
 def test_build_and_sort(self):
     autospec_method(self.collection.sort)
     count = 4
     builder, seq = mock.Mock(), range(count)
     instances = self.collection._build_and_sort(builder, seq)
     self.collection.sort.assert_called_with()
     assert_equal(builder.mock_calls, [mock.call(i) for i in seq])
     assert_length(instances, count)
     assert_equal(instances, self.collection.instances)
コード例 #33
0
ファイル: resource_test.py プロジェクト: wfxiang08/Tron
 def test_getChild_action_run_history(self):
     autospec_method(self.resource.get_run_from_identifier, return_value=None)
     action_name = 'action_name'
     action_runs = [mock.Mock(), mock.Mock()]
     self.job.action_graph.names = [action_name]
     self.job.runs.get_action_runs.return_value = action_runs
     resource = self.resource.getChild(action_name, None)
     assert_equal(resource.__class__, www.ActionRunHistoryResource)
     assert_equal(resource.action_runs, action_runs)
コード例 #34
0
ファイル: manager_test.py プロジェクト: wfxiang08/Tron
 def test_validate_with_fragment(self, mock_config_container):
     name = 'the_name'
     name_mapping = {'something': 'content', name: 'old_content'}
     autospec_method(self.manager.get_config_name_mapping)
     self.manager.get_config_name_mapping.return_value = name_mapping
     self.manager.validate_with_fragment(name, self.content)
     expected_mapping = dict(name_mapping)
     expected_mapping[name] = self.content
     mock_config_container.create.assert_called_with(expected_mapping)
コード例 #35
0
 def test_stop(self):
     autospec_method(self.node._fail_run)
     action_command = mock.create_autospec(
         actioncommand.ActionCommand,
         id=mock.Mock(),
     )
     self.node.run_states[action_command.id] = mock.Mock()
     self.node.stop(action_command)
     assert_equal(self.node._fail_run.call_count, 1)
コード例 #36
0
ファイル: actioncommand_test.py プロジェクト: Codeacious/Tron
 def test_create(self):
     serializer = mock.create_autospec(actioncommand.StringBufferStore)
     id, command = "id", "do a thing"
     autospec_method(self.factory.build_command)
     action_command = self.factory.create(id, command, serializer)
     assert_equal(action_command.id, id)
     assert_equal(action_command.command, self.factory.build_command.return_value)
     assert_equal(action_command.stdout, serializer.open.return_value)
     assert_equal(action_command.stderr, serializer.open.return_value)
コード例 #37
0
ファイル: manager_test.py プロジェクト: wfxiang08/Tron
 def test_write_config_new_name(self):
     name = 'filename2'
     path = self.manager.build_file_path(name)
     self.manifest.get_file_name.return_value = None
     autospec_method(self.manager.validate_with_fragment)
     self.manager.write_config(name, self.raw_content)
     assert_equal(manager.read(path), self.content)
     self.manifest.get_file_name.assert_called_with(name)
     self.manifest.add.assert_called_with(name, path)
コード例 #38
0
 def test_load_config(self):
     autospec_method(self.mcp.apply_config)
     self.mcp.config = mock.create_autospec(manager.ConfigManager)
     self.mcp._load_config()
     self.mcp.state_watcher.disabled.assert_called_with()
     self.mcp.apply_config.assert_called_with(
         self.mcp.config.load.return_value,
         reconfigure=False,
     )
コード例 #39
0
 def test_build_and_sort(self):
     autospec_method(self.collection.sort)
     count = 4
     builder, seq = mock.Mock(), range(count)
     instances = self.collection._build_and_sort(builder, seq)
     self.collection.sort.assert_called_with()
     assert_equal(builder.mock_calls, [mock.call(i) for i in seq])
     assert_length(instances, count)
     assert_equal(instances, self.collection.instances)
コード例 #40
0
ファイル: manager_test.py プロジェクト: Feriority/Tron
 def test_validate_with_fragment(self, mock_config_container):
     name = 'the_name'
     name_mapping = {'something': 'content', name: 'old_content'}
     autospec_method(self.manager.get_config_name_mapping)
     self.manager.get_config_name_mapping.return_value = name_mapping
     self.manager.validate_with_fragment(name, self.content)
     expected_mapping = dict(name_mapping)
     expected_mapping[name] = self.content
     mock_config_container.create.assert_called_with(expected_mapping)
コード例 #41
0
ファイル: manager_test.py プロジェクト: Feriority/Tron
 def test_write_config_new_name(self):
     name = 'filename2'
     path = self.manager.build_file_path(name)
     self.manifest.get_file_name.return_value = None
     autospec_method(self.manager.validate_with_fragment)
     self.manager.write_config(name, self.raw_content)
     assert_equal(manager.read(path), self.content)
     self.manifest.get_file_name.assert_called_with(name)
     self.manifest.add.assert_called_with(name, path)
コード例 #42
0
ファイル: job_test.py プロジェクト: ContextLogic/Tron
 def test_update(self):
     mock_scheduler = mock.create_autospec(job.JobScheduler)
     existing_scheduler = mock.create_autospec(job.JobScheduler)
     autospec_method(self.collection.get_by_name, return_value=existing_scheduler)
     assert self.collection.update(mock_scheduler)
     self.collection.get_by_name.assert_called_with(mock_scheduler.get_name())
     existing_scheduler.get_job().update_from_job.assert_called_with(
         mock_scheduler.get_job.return_value)
     existing_scheduler.schedule_reconfigured.assert_called_with()
コード例 #43
0
ファイル: resource_test.py プロジェクト: Codeacious/Tron
 def test_getChild_action_run_history(self):
     autospec_method(self.resource.get_run_from_identifier, return_value=None)
     action_name = 'action_name'
     action_runs = [mock.Mock(), mock.Mock()]
     self.job.action_graph.names = [action_name]
     self.job.runs.get_action_runs.return_value = action_runs
     resource = self.resource.getChild(action_name, None)
     assert_equal(resource.__class__, www.ActionRunHistoryResource)
     assert_equal(resource.action_runs, action_runs)
コード例 #44
0
 def test_is_done_true_because_blocked(self):
     self.run_map['action_name'].machine.state = ActionRun.STATE_FAILED
     self.run_map['second_name'].machine.state = ActionRun.STATE_QUEUED
     autospec_method(self.collection._is_run_blocked)
     blocked_second_action_run = lambda ar: ar == self.run_map['second_name'
                                                               ]
     self.collection._is_run_blocked.side_effect = blocked_second_action_run
     assert self.collection.is_done
     assert self.collection.is_failed
コード例 #45
0
 def test_update_from_config_changed(self, mock_factory):
     state_config = mock.Mock()
     autospec_method(self.watcher.shutdown)
     assert self.watcher.update_from_config(state_config)
     assert_equal(self.watcher.config, state_config)
     self.watcher.shutdown.assert_called_with()
     assert_equal(self.watcher.state_manager,
                  mock_factory.from_config.return_value)
     mock_factory.from_config.assert_called_with(state_config)
コード例 #46
0
ファイル: statemanager_test.py プロジェクト: Codeacious/Tron
 def test_update_from_config_changed(self, mock_factory):
     state_config = mock.Mock()
     autospec_method(self.watcher.shutdown)
     assert self.watcher.update_from_config(state_config)
     assert_equal(self.watcher.config, state_config)
     self.watcher.shutdown.assert_called_with()
     assert_equal(self.watcher.state_manager,
         mock_factory.from_config.return_value)
     mock_factory.from_config.assert_called_with(state_config)
コード例 #47
0
ファイル: jobrun_test.py プロジェクト: shaikhanas1993/Tron
    def test_cleanup(self):
        autospec_method(self.job_run.clear_observers)
        self.job_run.output_path = mock.create_autospec(filehandler.OutputPath)
        self.job_run.cleanup()

        self.job_run.clear_observers.assert_called_with()
        self.job_run.output_path.delete.assert_called_with()
        assert not self.job_run.node
        assert not self.job_run.action_graph
        assert not self.job_run.action_runs
コード例 #48
0
ファイル: service_test.py プロジェクト: Codeacious/Tron
 def setup_service(self):
     self.config = mock.MagicMock()
     self.instances = mock.create_autospec(
         serviceinstance.ServiceInstanceCollection,
         stop=mock.Mock(), start=mock.Mock(), state_data=mock.Mock(),
         restore=mock.Mock())
     self.service = service.Service(self.config, self.instances)
     autospec_method(self.service.watch)
     self.service.repair_callback = mock.create_autospec(
         eventloop.UniqueCallback)
コード例 #49
0
ファイル: jobrun_test.py プロジェクト: wfxiang08/Tron
    def test_handler_with_startable(self):
        startable_run = mock.create_autospec(actionrun.ActionRun)
        self.job_run.action_runs.get_startable_action_runs = lambda: [startable_run]
        autospec_method(self.job_run.finalize)
        self.action_run.is_broken = False

        self.job_run.handler(self.action_run, mock.Mock())
        self.job_run.notify.assert_called_with(self.job_run.NOTIFY_STATE_CHANGED)
        startable_run.start.assert_called_with()
        assert not self.job_run.finalize.mock_calls
コード例 #50
0
ファイル: manager_test.py プロジェクト: strategist922/Tron
 def test_write_config(self):
     name = 'filename'
     path = self.manager.build_file_path(name)
     self.manifest.get_file_name.return_value = path
     autospec_method(self.manager.validate_fragment)
     self.manager.write_config(name, self.raw_content)
     assert_equal(manager.read(path), self.content)
     self.manifest.get_file_name.assert_called_with(name)
     assert not self.manifest.add.call_count
     self.manager.validate_fragment.assert_called_with(name, self.content)
コード例 #51
0
ファイル: actioncommand_test.py プロジェクト: kesre/Tron
 def test_create(self):
     serializer = mock.create_autospec(actioncommand.StringBufferStore)
     id, command = 'id', 'do a thing'
     autospec_method(self.factory.build_command)
     action_command = self.factory.create(id, command, serializer)
     assert_equal(action_command.id, id)
     assert_equal(action_command.command,
                  self.factory.build_command.return_value)
     assert_equal(action_command.stdout, serializer.open.return_value)
     assert_equal(action_command.stderr, serializer.open.return_value)
コード例 #52
0
ファイル: controller_test.py プロジェクト: yenNSTH/Tron
 def test_update_config(self):
     autospec_method(self.controller.strip_header)
     name, content, config_hash = None, mock.Mock(), mock.Mock()
     self.manager.get_hash.return_value = config_hash
     assert not self.controller.update_config(name, content, config_hash)
     striped_content = self.controller.strip_header.return_value
     self.manager.write_config.assert_called_with(name, striped_content)
     self.mcp.reconfigure.assert_called_with()
     self.controller.strip_header.assert_called_with(name, content)
     self.manager.get_hash.assert_called_with(name)
コード例 #53
0
ファイル: jobrun_test.py プロジェクト: wfxiang08/Tron
 def test_build_new_run_manual(self):
     autospec_method(self.run_collection.remove_old_runs)
     run_time = datetime.datetime(2012, 3, 14, 15, 9, 26)
     mock_job = build_mock_job()
     job_run = self.run_collection.build_new_run(
         mock_job, run_time, self.mock_node, True)
     assert_in(job_run, self.run_collection.runs)
     self.run_collection.remove_old_runs.assert_called_with()
     assert_equal(job_run.run_num, 5)
     assert job_run.manual
コード例 #54
0
ファイル: job_test.py プロジェクト: kesre/Tron
 def test_update(self):
     mock_scheduler = mock.create_autospec(job.JobScheduler)
     existing_scheduler = mock.create_autospec(job.JobScheduler)
     autospec_method(self.collection.get_by_name,
                     return_value=existing_scheduler)
     assert self.collection.update(mock_scheduler)
     self.collection.get_by_name.assert_called_with(
         mock_scheduler.get_name())
     existing_scheduler.get_job().update_from_job.assert_called_with(
         mock_scheduler.get_job.return_value)
     existing_scheduler.schedule_reconfigured.assert_called_with()
コード例 #55
0
 def test_update_config_failure(self):
     autospec_method(self.controller.strip_header)
     striped_content = self.controller.strip_header.return_value
     name, content, config_hash = None, mock.Mock(), mock.Mock()
     self.manager.get_hash.return_value = config_hash
     self.manager.write_config.side_effect = ConfigError("It broke")
     error = self.controller.update_config(name, striped_content,
                                           config_hash)
     assert_equal(error, "It broke")
     self.manager.write_config.assert_called_with(name, striped_content)
     assert not self.mcp.reconfigure.call_count
コード例 #56
0
 def test_read_config_named(self):
     name = 'some_name'
     autospec_method(self.controller._get_config_content)
     autospec_method(self.controller.render_template)
     resp = self.controller.read_config(name)
     self.controller._get_config_content.assert_called_with(name)
     self.controller.render_template.assert_called_with(
         self.controller._get_config_content.return_value)
     assert_equal(resp['config'],
                  self.controller.render_template.return_value)
     assert_equal(resp['hash'], self.manager.get_hash.return_value)
コード例 #57
0
ファイル: actionrun_test.py プロジェクト: dennistu1994/Tron
    def test_is_done_true_because_blocked(self):
        self.run_map['action_name'].machine.state = ActionRun.FAILED
        self.run_map['second_name'].machine.state = ActionRun.QUEUED
        autospec_method(self.collection._is_run_blocked)

        def blocked_second_action_run(ar, ):
            return ar == self.run_map['second_name']

        self.collection._is_run_blocked.side_effect = blocked_second_action_run
        assert self.collection.is_done
        assert self.collection.is_failed
コード例 #58
0
ファイル: service_test.py プロジェクト: wfxiang08/Tron
 def setup_service(self):
     self.config = mock.MagicMock()
     self.instances = mock.create_autospec(
         serviceinstance.ServiceInstanceCollection,
         stop=mock.Mock(),
         start=mock.Mock(),
         state_data=mock.Mock(),
         restore=mock.Mock())
     self.service = service.Service(self.config, self.instances)
     autospec_method(self.service.watch)
     self.service.repair_callback = mock.create_autospec(
         eventloop.UniqueCallback)
コード例 #59
0
 def test_build_action_command(self, mock_filehandler):
     autospec_method(self.action_run.watch)
     serializer = mock_filehandler.OutputStreamSerializer.return_value
     action_command = self.action_run.build_action_command()
     assert_equal(action_command, self.action_run.action_command)
     assert_equal(action_command, self.action_runner.create.return_value)
     self.action_runner.create.assert_called_with(self.action_run.id,
                                                  self.action_run.command,
                                                  serializer)
     mock_filehandler.OutputStreamSerializer.assert_called_with(
         self.action_run.output_path)
     self.action_run.watch.assert_called_with(action_command)