예제 #1
0
def test_compile_writes_file_manifest():
    file_dict = paths_to_fs_dict({
        'repo/public/Properties/dir/prop_env_spec_pub': 'prop_env_spec_pub_overridden',
        'repo/public/Properties/dir/prop_env_spec_priv': 'prop_env_spec_priv_overridden',
        'repo/public/Properties/ENVIRONMENT_SPECIFIC/env/dir/prop_env_spec_pub': 'prop_env_spec_pub_contents',
        'repo/public/Properties/ENVIRONMENT_SPECIFIC/env/dir/prop_env_spec_priv': 'prop_env_spec_priv_overridden',
        'repo/ops_private/Properties/ENVIRONMENT_SPECIFIC/env/dir/prop_env_spec_priv': 'prop_env_spec_priv_contents',
        'repo/public/dir/common_pub': 'common_pub_contents',
        'repo/ops_private/dir/common_priv': 'common_priv_overridden',
    })

    with setup_temp_dir(file_dict) as basedir:
        sources = [
            os.path.join(basedir, 'repo', 'public'),
            os.path.join(basedir, 'repo', 'ops_private')
        ]
        compile_directories(sources, os.path.join(basedir, 'dest'), 'env', False)

        with open(os.path.join(basedir, 'dest', 'etc', 'mapped_files.json'), 'r') as manifest_file:
            manifest = json.load(manifest_file)
            assert_equals(
                {
                    os.path.join(basedir, 'dest/Properties/dir/prop_env_spec_pub'): os.path.join(basedir, 'repo/public/Properties/ENVIRONMENT_SPECIFIC/env/dir/prop_env_spec_pub'),
                    os.path.join(basedir, 'dest/Properties/dir/prop_env_spec_priv'): os.path.join(basedir, 'repo/ops_private/Properties/ENVIRONMENT_SPECIFIC/env/dir/prop_env_spec_priv'),
                    os.path.join(basedir, 'dest/dir/common_priv'): os.path.join(basedir, 'repo/ops_private/dir/common_priv'),
                    os.path.join(basedir, 'dest/dir/common_pub'): os.path.join(basedir, 'repo/public/dir/common_pub'),
                },
                manifest
            )
예제 #2
0
def test_compile_deletes_non_git():
    file_dict = paths_to_fs_dict({
        'repo/public/Properties/dir/prop_env_spec_pub': 'prop_env_spec_pub_overridden',
        'repo/public/Properties/dir/prop_env_spec_priv': 'prop_env_spec_priv_overridden',
        'repo/public/Properties/ENVIRONMENT_SPECIFIC/env/dir/prop_env_spec_pub': 'prop_env_spec_pub_contents',
        'repo/public/Properties/ENVIRONMENT_SPECIFIC/env/dir/prop_env_spec_priv': 'prop_env_spec_priv_overridden',
        'repo/ops_private/Properties/ENVIRONMENT_SPECIFIC/env/dir/prop_env_spec_priv': 'prop_env_spec_priv_contents',
        'repo/public/dir/common_pub': 'common_pub_contents',
        'repo/public/dir/common_priv': 'common_priv_overridden',
        'repo/ops_private/dir/common_priv': 'common_priv_contents',
        'dest/.git/git_contents': 'git_contents',
        'etc/subdir/not_git_contents': 'not_git_contents',
    })

    with setup_temp_dir(file_dict) as basedir:
        sources = [
            os.path.join(basedir, 'repo', 'public'),
            os.path.join(basedir, 'repo', 'ops_private')
        ]
        compile_directories(sources, os.path.join(basedir, 'dest'), 'env', False)
        assert os.path.exists(os.path.join(basedir, 'dest', '.git', 'git_contents'))
        assert not os.path.exists(os.path.join(basedir, 'dest', 'etc', 'subdir', 'not_git_contents'))