Exemplo n.º 1
0
def test_it_full_single_package_as_list(request, mocker,
                                        skip_app_logging_reconfiguration):
    logger.info(f'{request._pyfuncitem.name}()')

    file_manager = ExitStack()

    pck = '.'.join(['tests_data', __package__, 'it'])

    exp_config_yml = file_manager.enter_context(path(pck, "config.yml"))
    exp_input = file_manager.enter_context(path(pck, 'requirements-src.txt'))
    exp_output = file_manager.enter_context(path(pck, 'requirements-dest.txt'))
    exp_package = 'lxml'
    exp_version = '4.3.3'
    exp_line = f'{exp_package}=={exp_version}'

    argsv = f'--config_file={exp_config_yml} ' \
            f'--source={exp_input} ' \
            f'--destination={exp_output} ' \
            f'--add={exp_package}:{exp_version}, ' \
        .split()
    app.main(argsv)

    validate_result(input_path=exp_input,
                    output_path=exp_output,
                    new_lines=[exp_line],
                    removed_lines=_calc_removed_lines_lines(exp_config_yml))
Exemplo n.º 2
0
def test_main_unofficial_api(request, mocker, initCwd):
    logger.info(f'{request._pyfuncitem.name}()')

    _parse_config_return_value = None

    def _mock_parse_config(argumentParser=None, args=None):
        ret = _real_parse_config(argumentParser, args)
        nonlocal _parse_config_return_value
        _parse_config_return_value = ret
        return ret

    mocker.patch.object(app, 'fixabscwd', autospec=True, spec_set=True)

    #mocker.spy(init_app_conf, 'parse_config')
    mocker.patch.object(init_app_conf, 'parse_config', side_effect=_mock_parse_config, autospec=True, spec_set=True)
    mocker.patch.object(app, 'run', autospec=True, spec_set=True)


    arg_source = 'treeroot.source=requirements-src.txt'
    arg_destination = 'treeroot.destination=requirements-dest.txt'
    arg_remove = 'treeroot.remove=datashape,menuinst'

    exp_source = f'--{arg_source}'
    exp_destination = f'--{arg_destination}'
    exp_remove = f'--{arg_remove}'

    argsv = f'--{arg_source} ' \
    f'--{arg_destination} ' \
    f'--{arg_remove} ' \
    '--general.config.file=config.yml' \
        .split()

    app.main(argsv)

    pytest.assume(init_app_conf.parse_config.call_count == 1)
    _, kwargs =  init_app_conf.parse_config.call_args
    source, destination, remove, _, _ = kwargs['args']
    pytest.assume( (exp_source, exp_destination, exp_remove) == (source, destination, remove) )

    pytest.assume(app.run.call_count == 1)
    _, run_d = app.run.call_args

    pytest.assume(_parse_config_return_value == run_d)
Exemplo n.º 3
0
def test_it_full_single_package_exist_as_list(
        request, mocker, skip_app_logging_reconfiguration):
    logger.info(f'{request._pyfuncitem.name}()')

    file_manager = ExitStack()
    pck = '.'.join(['tests_data', __package__, 'it'])

    exp_config_yml = file_manager.enter_context(path(pck, "config.yml"))
    exp_input = file_manager.enter_context(path(pck, 'requirements-src.txt'))
    exp_output = file_manager.enter_context(path(pck, 'requirements-dest.txt'))
    exp_package = 'numpy'
    exp_version = '1.16.2'

    argsv = f'--config_file={exp_config_yml} ' \
            f'--source={exp_input} ' \
            f'--destination={exp_output} ' \
            f'--add={exp_package}:{exp_version}, ' \
        .split()

    with pytest.raises(ValueError, match='Mutual_Exclusion'):
        app.main(argsv)
Exemplo n.º 4
0
def test_it_remove_single_package_last(request, mocker,
                                       skip_app_logging_reconfiguration):
    logger.info(f'{request._pyfuncitem.name}()')
    file_manager = ExitStack()

    pck = '.'.join(['tests_data', __package__, 'it'])

    exp_config_yml = file_manager.enter_context(path(pck, "config.yml"))
    exp_input = file_manager.enter_context(path(pck, 'requirements-src.txt'))
    exp_output = file_manager.enter_context(path(pck, 'requirements-dest.txt'))

    remove_package = 'wstools'


    argsv = f'--config_file={exp_config_yml} ' \
            f'--source={exp_input} ' \
            f'--destination={exp_output} ' \
            f'--remove={remove_package} ' \
        .split()
    app.main(argsv)

    validate_result(input_path=exp_input,
                    output_path=exp_output,
                    removed_lines=[remove_package])
Exemplo n.º 5
0
def main():
    app.main()