Exemple #1
0
    def test_discover_transforms_ignore_test_dirs(self, load_manifest_at_path, transforms_fixtures_path, simple_transform_manifest_yml, tmpdir):
        repo_dir = tmpdir.mkdir('manifests')
        tests_dir = repo_dir.mkdir('transforms').mkdir('parser').mkdir('tests')
        nested_tests_dir = tests_dir.mkdir('nested').mkdir('deeply')

        copy_tree(transforms_fixtures_path, str(repo_dir))

        for path in [tests_dir, nested_tests_dir]:
            with open(os.path.join(str(path), 'manifest.yml'), 'w') as fd:
                fd.write(simple_transform_manifest_yml)

        runner.discover_transforms(repo_dir)

        loaded_paths = [c[0][0] for c in load_manifest_at_path.call_args_list]
        assert tests_dir not in loaded_paths, 'the "tests" directory was not skipped'
        assert nested_tests_dir not in loaded_paths, 'the nested "tests" directory was not skipped'
Exemple #2
0
    def test_discover_transforms_ignore_invalid_yaml_manifest(self, transforms_fixtures_path, tmpdir):
        repo_dir = str(tmpdir.mkdir('transforms'))
        copy_tree(transforms_fixtures_path, repo_dir)

        os.mkdir(os.path.join(repo_dir, 'invalid-yaml-transform'))
        with open(os.path.join(repo_dir, 'invalid-yaml-transform', 'manifest.yml'), 'w') as fd:
            fd.write('not really a manifest')

        transforms = runner.discover_transforms(repo_dir)

        assert sorted(transforms.keys()) == sorted([
            'morgue-splitter', 'morgues-download', 'parser'
        ])
Exemple #3
0
    def test_discover_transforms(self, transforms_fixtures_path):
        transforms = runner.discover_transforms(transforms_fixtures_path)

        names_and_paths = [
            (name, transform['path'])
            for name, transform in transforms.items()
        ]

        assert sorted(names_and_paths) == sorted([
            ('morgue-splitter', '{repo_dir}/transforms/splitter'.format(repo_dir=transforms_fixtures_path)),
            ('morgues-download', '{repo_dir}/transforms/download'.format(repo_dir=transforms_fixtures_path)),
            ('parser', '{repo_dir}/transforms/parser'.format(repo_dir=transforms_fixtures_path))
        ])
Exemple #4
0
    def test_discover_transforms_ignore_missing_required_manifest_field(self, required_key, transforms_fixtures_path, tmpdir):
        repo_dir = str(tmpdir.mkdir('transforms'))
        copy_tree(transforms_fixtures_path, repo_dir)

        yaml = re.sub(r'^([ \t]*{}\:)'.format(required_key), r'# \1', """
name: invalid-manifest-transform
type: transform
run-command: python run.py
        """, flags=re.MULTILINE)
        os.mkdir(os.path.join(repo_dir, 'invalid-transform'))
        with open(os.path.join(repo_dir, 'invalid-transform', 'manifest.yml'), 'w') as fd:
            fd.write(yaml)

        transforms = runner.discover_transforms(repo_dir)

        assert sorted(transforms.keys()) == [
            'morgue-splitter', 'morgues-download', 'parser'
        ]