Esempio n. 1
0
def test_update_SHOULD_update_repoassit_properly():
    cwd = TESTS_SETUPS_PATH / 'test_update_SHOULD_update_repoassit_properly'
    setup_test(cwd, clean=False)

    pygittools.init(cwd)

    args = settings.Options()
    args.update = '.'

    repoassit_path = cwd / 'repoassist'
    repoassist_templates_path = cwd / 'repoassist/templates'

    if repoassit_path.exists():
        shutil.rmtree(repoassit_path)

    repoassit_path.mkdir(exist_ok=True)
    repoassist_templates_path.mkdir(exist_ok=True)

    main_file_path = repoassit_path / settings.FileName.MAIN
    main_file_path.touch()
    assert main_file_path.read_text() == ''

    cli.update(args, add_to_tree=True)

    assert main_file_path.read_text() != ''
    assert repoassit_path / settings.FileName.PYINIT in list(
        repoassit_path.iterdir())

    if repoassit_path.exists():
        shutil.rmtree(repoassit_path)

    teardown_test(cwd, clean=False)
Esempio n. 2
0
def test_update_SHOULD_raise_error_WHEN_repoassist_not_found():
    cwd = TESTS_SETUPS_PATH / 'test_update_SHOULD_raise_error_WHEN_repoassist_not_found'
    setup_test(cwd)

    args = settings.Options()
    args.update = '.'

    with pytest.raises(exceptions.RepoassistNotFoundError):
        cli.update(args)

    teardown_test(cwd)
Esempio n. 3
0
def update_repoassist_setup(cwd):
    config = settings.Config(**_DEFAULT_CONFIG)
    options = settings.Options()
    options.force = True
    options.cloud = config.is_cloud
    options.sample_layout = config.is_sample_layout
    options.project_type = config.project_type

    repoassit_path = cwd / 'repoassist'
    repoassist_templates_path = cwd / 'repoassist/templates'
    repoassist_templates_path.mkdir(exist_ok=True, parents=True)

    return config, options, repoassit_path, repoassist_templates_path
Esempio n. 4
0
def test_update_SHOULD_raise_error_WHEN_config_not_found():
    cwd = TESTS_SETUPS_PATH / 'test_update_SHOULD_raise_error_WHEN_config_not_found'
    setup_test(cwd)

    args = settings.Options()
    args.update = '.'

    (cwd / 'repoassist').mkdir()

    with pytest.raises(exceptions.ConfigError):
        cli.update(args)

    teardown_test(cwd)
Esempio n. 5
0
def test_cli_SHOULD_raise_error_WHEN_specified_config_not_exists():
    cwd = TESTS_SETUPS_PATH / 'test_cli_SHOULD_raise_error_WHEN_specified_config_not_exists'
    setup_test(cwd)

    test_project_dir = 'my_project'

    args = settings.Options()
    args.repo_path = test_project_dir
    args.config = 'config/package_repo.cfg'

    with pytest.raises(exceptions.FileNotFoundError):
        cli.generate(args, cwd)

    teardown_test(cwd)