Exemple #1
0
    def test_get_cookbook_steps(self, mock_pf):
        # This asserts that a list of steps is added to the stack when `get_cookbook_steps` if called
        # First do the work:
        test_runner = DummyRunner(Event(self.path_to_event_file))
        test_runner.cmf = CrashMoveFolder(self.path_to_cmf_file)
        initial_step = plugin_controller.get_cookbook_steps(
            test_runner, None, dry_run=True, verify_on_creation=False)
        main_stack.process_stack(initial_step, None)

        # Now get the information out of the mock:
        found_list_of_steps = False
        for call in mock_pf.call_args_list:
            try:
                # print()
                # print('---------------------')
                # print('test_get_cookbook_steps')
                # print(call)
                # print('END:test_get_cookbook_steps')
                # print('---------------------')
                # retrieved_result = call[1]['result']
                retrieved_result = call[1].get('result', None)
                if all([isinstance(stp, Step) for stp in retrieved_result]):
                    # print('found_list_of_steps=True')
                    found_list_of_steps = True
            except TypeError:
                pass

        self.assertTrue(found_list_of_steps)
def build_maps(humevent_desc_path, map_number, dry_run):
    # build_steps = config_verify.get_config_verify_steps(args.cmf_desc_path, ['.lyr'])
    # build_steps.append(cnc.get_defaultcmf_step_list(args.cmf_desc_path, False))
    # build_steps.append(cnc.get_active_data_step_list(args.humevent_desc_path, True))
    # main_stack.process_stack(build_steps)
    my_runner = process_stack(plugin_controller.get_plugin_step(), humevent_desc_path)
    process_stack(plugin_controller.get_cookbook_steps(my_runner, map_number, dry_run), None)
def noun_gisdata_print_output(args):
    if args.verb == VERB_VERIFY:
        nc_steps = cnc.get_active_data_step_list(args.humevent_desc_path)
        process_stack(nc_steps, None)
        # print(nc_steps)
    else:
        raise NotImplementedError(args)
def noun_defaultcmf_print_output(args):
    if args.verb == VERB_VERIFY:
        cv_steps = config_verify.get_config_verify_steps(args.cmf_desc_path, ['.lyr'])
        # process_stack(cv_steps, None)
        cv_steps.extend(cnc.get_defaultcmf_step_list(args.cmf_desc_path))
        process_stack(cv_steps, None)
    else:
        raise NotImplementedError(args)
    def test_simple_step_list(self, mock_hft):
        # mock_hft is purely to prevent the console from becoming too clutered when running unittests
        mock_hft.return_value = False

        starter_list = ['AAA', 'BBB', 'CCC', 'DDD']

        test_cases = [
            ('list', [], ['AAA', 'BBB', 'CCC', 'DDD']),
            ('dict', {}, {'AAA': 'AAA', 'BBB': 'BBB', 'CCC': 'CCC', 'DDD': 'DDD'}),
            ('string', '', 'AAABBBCCCDDD')
        ]

        for state_type, initial_state, expected_state in test_cases:
            starter_steps = self.build_example_steps(starter_list, state_type)
            final_state = process_stack(starter_steps, initial_state)
            self.assertEqual(expected_state, final_state)
    def test_add_multiple_steps_into_stack(self, mock_hft):
        # mock_hft is purely to prevent the console from becoming too clutered when running unittests
        mock_hft.return_value = False

        starter_list = ['AAA', 'BBB', 'CCC', 'DDD']

        test_cases = [
            ('list', [], ['AAA', 'BBB', '111', '222', '333', 'DDD']),
            ('dict', {}, {'AAA': 'AAA', 'BBB': 'BBB', '111': '111', '222': '222', '333': '333', 'DDD': 'DDD'}),
            ('string', '', 'AAABBB111222333DDD')
        ]

        for state_type, initial_state, expected_state in test_cases:
            def get_inject_steps(**kwargs):
                return self.build_example_steps(['111', '222', '333'], state_type)

            starter_steps = self.build_example_steps(starter_list, state_type)
            # change the func on one of the step, to a function which returns more Step objects
            starter_steps[2].func = get_inject_steps
            final_state = process_stack(starter_steps, initial_state)
            self.assertEqual(expected_state, final_state)
    def test_get_args(self, mock_hft):
        # mock_hft is purely to prevent the console from becoming too clutered when running unittests
        mock_hft.return_value = False

        process_stack(self._get_demo_steps(secs=0.1), None)
        self.assertTrue(True)