def test_upload_on_branch_azure(upload_on_branch_recipe, jinja_env):
    cnfgr_fdstk.render_azure(jinja_env=jinja_env,
                             forge_config=upload_on_branch_recipe.config,
                             forge_dir=upload_on_branch_recipe.recipe)
    # Check that the parameter is in the configuration.
    assert 'upload_on_branch' in upload_on_branch_recipe.config
    assert upload_on_branch_recipe.config['upload_on_branch'] == 'foo-branch'
    # Check that the parameter is in the generated file.
    with open(
            os.path.join(upload_on_branch_recipe.recipe, '.azure-pipelines',
                         'azure-pipelines-osx.yml')) as fp:
        content_osx = yaml.load(fp)
    assert 'UPLOAD_ON_BRANCH="foo-branch"' in content_osx['jobs'][0]['steps'][
        -1]['script']
    assert 'BUILD_SOURCEBRANCHNAME' in content_osx['jobs'][0]['steps'][-1][
        'script']

    with open(
            os.path.join(upload_on_branch_recipe.recipe, '.azure-pipelines',
                         'azure-pipelines-win.yml')) as fp:
        content_win = yaml.load(fp)
    assert 'UPLOAD_ON_BRANCH=foo-branch' in content_win['jobs'][0]['steps'][
        -1]['script']
    assert 'BUILD_SOURCEBRANCHNAME' in content_win['jobs'][0]['steps'][-1][
        'script']

    with open(
            os.path.join(upload_on_branch_recipe.recipe, '.azure-pipelines',
                         'azure-pipelines-linux.yml')) as fp:
        content_lin = yaml.load(fp)
    assert 'UPLOAD_ON_BRANCH="foo-branch"' in content_lin['jobs'][0]['steps'][
        1]['script']
    assert 'BUILD_SOURCEBRANCHNAME' in content_lin['jobs'][0]['steps'][1][
        'script']
def test_azure_with_empty_yum_reqs_raises(py_recipe, jinja_env):
    with open(os.path.join(py_recipe.recipe, "recipe", "yum_requirements.txt"),
              "w") as f:
        f.write("# effectively empty")
    with pytest.raises(ValueError):
        cnfgr_fdstk.render_azure(
            jinja_env=jinja_env,
            forge_config=py_recipe.config,
            forge_dir=py_recipe.recipe,
        )
def test_migrator_recipe(recipe_migration_cfep9, jinja_env):
    cnfgr_fdstk.render_azure(
        jinja_env=jinja_env,
        forge_config=recipe_migration_cfep9.config,
        forge_dir=recipe_migration_cfep9.recipe,
    )

    with open(
            os.path.join(recipe_migration_cfep9.recipe, ".ci_support",
                         "linux_python2.7.yaml")) as fo:
        variant = yaml.safe_load(fo)
        assert variant["zlib"] == ["1000"]
def test_py_matrix_on_azure(py_recipe, jinja_env):
    cnfgr_fdstk.render_azure(jinja_env=jinja_env,
                             forge_config=py_recipe.config,
                             forge_dir=py_recipe.recipe)
    # this configuration should be run
    assert py_recipe.config["azure"]["enabled"]
    # no appveyor.yaml should have been written.  Nothing else, either, since we only ran
    #     appveyor render.  No matrix dir should exist.
    matrix_dir = os.path.join(py_recipe.recipe, ".ci_support")
    assert os.path.isdir(matrix_dir)
    # single matrix entry - readme is generated later in main function
    assert len(os.listdir(matrix_dir)) == 8
def test_migrator_downgrade_recipe(recipe_migration_cfep9_downgrade,
                                   jinja_env):
    """
    Assert that even when we have two migrations targeting the same file the correct one wins.
    """
    cnfgr_fdstk.render_azure(
        jinja_env=jinja_env,
        forge_config=recipe_migration_cfep9_downgrade.config,
        forge_dir=recipe_migration_cfep9_downgrade.recipe,
    )
    assert len(
        os.listdir(
            os.path.join(recipe_migration_cfep9_downgrade.recipe,
                         '.ci_support', 'migrations'))) == 2

    with open(
            os.path.join(recipe_migration_cfep9_downgrade.recipe,
                         ".ci_support", "linux_python2.7.yaml")) as fo:
        variant = yaml.safe_load(fo)
        assert variant["zlib"] == ["1000"]
def test_migrator_compiler_version_recipe(recipe_migration_win_compiled,
                                          jinja_env):
    """
    Assert that even when we have two migrations targeting the same file the correct one wins.
    """
    cnfgr_fdstk.render_azure(
        jinja_env=jinja_env,
        forge_config=recipe_migration_win_compiled.config,
        forge_dir=recipe_migration_win_compiled.recipe,
    )
    assert len(
        os.listdir(
            os.path.join(recipe_migration_win_compiled.recipe, '.ci_support',
                         'migrations'))) == 1

    rendered_variants = os.listdir(
        os.path.join(recipe_migration_win_compiled.recipe, ".ci_support"))

    assert 'win_c_compilervs2008python2.7target_platformwin-32.yaml' in rendered_variants
    assert 'win_c_compilervs2008python2.7target_platformwin-64.yaml' in rendered_variants
    assert 'win_c_compilervs2017python3.5target_platformwin-32.yaml' in rendered_variants
    assert 'win_c_compilervs2017python3.5target_platformwin-64.yaml' in rendered_variants