예제 #1
0
    def test_no_existing_source_file(self):
        """ should succeed even if the step has no source file """

        support.create_project(self, 'richfield')
        support.add_step(self, 'first')

        project = cauldron.project.get_internal_project()
        step = project.steps[0]
        r = Response()

        self.assertTrue(
            systems.remove(step.source_path),
            'should have removed source file'
        )

        result = step_actions.modify_step(
            response=r,
            project=project,
            name=step.filename,
            new_name='solo',
            title='Only Step'
        )

        new_step = project.steps[0]
        self.assertTrue(result)
        self.assertTrue(os.path.exists(new_step.source_path))
예제 #2
0
파일: __init__.py 프로젝트: sernst/cauldron
def initialize_results_path(results_path: str):
    """

    :param results_path:
    :return:
    """

    dest_path = environ.paths.clean(results_path)
    if not os.path.exists(dest_path):
        os.makedirs(dest_path)

    web_src_path = environ.paths.resources('web')
    for item in os.listdir(web_src_path):
        item_path = os.path.join(web_src_path, item)
        out_path = os.path.join(dest_path, item)

        systems.remove(out_path)

        if os.path.isdir(item_path):
            shutil.copytree(item_path, out_path)
        else:
            shutil.copy2(item_path, out_path)
예제 #3
0
    def test_remove_folder_success(self):
        """ should remove file when os.remove succeeds """

        path = 'NOT-REAL-PATH'
        with ExitStack() as stack:
            exists = stack.enter_context(patch('os.path.exists'))
            exists.return_value = True

            is_file = stack.enter_context(patch('os.path.isfile'))
            is_file.return_value = False

            remove_tree = stack.enter_context(patch('shutil.rmtree'))
            remove_tree.return_value = True

            self.assertTrue(systems.remove(path))
            exists.assert_called_with(path)
            self.assertEqual(remove_tree.call_count, 1)
예제 #4
0
    def test_remove_folder_fail(self):
        """ should fail to remove folder when os.remove fails """

        path = 'NOT-REAL-PATH'
        with ExitStack() as stack:
            exists = stack.enter_context(patch('os.path.exists'))
            exists.return_value = True

            is_file = stack.enter_context(patch('os.path.isfile'))
            is_file.return_value = False

            remove_tree = stack.enter_context(patch('shutil.rmtree'))
            remove_tree.side_effect = IOError('FAKE ERROR')

            self.assertFalse(systems.remove(path))
            exists.assert_called_with(path)
            self.assertEqual(remove_tree.call_count, 3)
예제 #5
0
    def test_no_existing_source_file(self):
        """ should succeed even if the step has no source file """

        support.create_project(self, 'richfield')
        support.add_step(self, 'first')

        project = cauldron.project.get_internal_project()
        step = project.steps[0]
        r = Response()

        self.assertTrue(systems.remove(step.source_path),
                        'should have removed source file')

        result = step_actions.modify_step(response=r,
                                          project=project,
                                          name=step.filename,
                                          new_name='solo',
                                          title='Only Step')

        new_step = project.steps[0]
        self.assertTrue(result)
        self.assertTrue(os.path.exists(new_step.source_path))
예제 #6
0
    def test_remove_no_path(self):
        """ should abort removal if path is None """

        self.assertFalse(systems.remove(None))