def test_build_repo_json_smoke_test(tmpdir): package_list = tmpdir.join('package-list') package_list.write('\n'.join((json.dumps(info) for info in ( { 'filename': 'ocflib-2016.12.10.1.48-py2.py3-none-any.whl', 'uploaded_by': 'ckuehl', 'upload_timestamp': 1515783971, 'hash': 'md5=b1946ac92492d2347c6235b4d2611184', }, { 'filename': 'numpy-1.11.0rc1.tar.gz', 'upload_timestamp': 1515783971, }, { 'filename': 'scikit-learn-0.15.1.tar.gz', }, ))) + '\n') main.main(( '--package-list-json', package_list.strpath, '--output-dir', tmpdir.strpath, '--packages-url', '../../pool/', )) assert tmpdir.join('simple').check(dir=True) assert tmpdir.join('simple', 'index.html').check(file=True) assert tmpdir.join('simple', 'ocflib').check(dir=True) assert tmpdir.join('simple', 'ocflib', 'index.html').check(file=True)
def test_build_repo_partial_rebuild_new_version_only(tmp_path): package_list = ( {"filename": "a-0.0.1.tar.gz"}, {"filename": "b-0.0.1.tar.gz"}, ) previous_packages = tmp_path / 'previous-packages' packages = tmp_path / 'packages' _write_json_package_list(previous_packages, package_list) _write_json_package_list( packages, package_list + ({"filename": "b-0.0.2.tar.gz"},), ) main.main(( '--previous-package-list-json', str(previous_packages), '--package-list-json', str(packages), '--output-dir', str(tmp_path), '--packages-url', '../../pool/', )) assert not (tmp_path / 'simple' / 'index.html').is_file() assert not (tmp_path / 'simple' / 'a').is_dir() assert not (tmp_path / 'pypi' / 'a').is_dir() assert (tmp_path / 'simple' / 'b' / 'index.html').is_file() assert (tmp_path / 'pypi' / 'b' / 'json').is_file() assert (tmp_path / 'pypi' / 'b' / '0.0.1' / 'json').is_file() assert (tmp_path / 'index.html').is_file() assert (tmp_path / 'changelog').is_dir()
def test_build_repo_no_generate_timestamp(tmpdir): package_list = tmpdir.join('package-list') package_list.write('pkg-1.0.tar.gz\n') main.main(( '--package-list', package_list.strpath, '--output-dir', tmpdir.strpath, '--packages-url', '../../pool', '--no-generate-timestamp', )) for p in ('simple/index.html', 'simple/pkg/index.html'): assert 'Generated on' not in tmpdir.join(p).read()
def test_build_repo_smoke_test(tmpdir): package_list = tmpdir.join('package-list') package_list.write('ocflib-2016.12.10.1.48-py2.py3-none-any.whl\n') main.main(( '--package-list', package_list.strpath, '--output-dir', tmpdir.strpath, '--packages-url', '../../pool/', )) assert tmpdir.join('simple').check(dir=True) assert tmpdir.join('simple', 'index.html').check(file=True) assert tmpdir.join('simple', 'ocflib').check(dir=True) assert tmpdir.join('simple', 'ocflib', 'index.html').check(file=True) assert tmpdir.join('pypi', 'ocflib', 'json').check(file=True) assert tmpdir.join('pypi', 'ocflib', '2016.12.10.1.48', 'json').check(file=True)
def install_packages(path, package_names): """Deploy fake packages with the given names into path.""" pool = path.join('pool').mkdir() for package in package_names: make_package(pool.join(package).strpath) package_list = path.join('package-list') package_list.write('\n'.join(package_names) + '\n') main.main(( '--package-list', package_list.strpath, '--output-dir', path.strpath, '--packages-url', '../../pool/', ))
def test_build_repo_even_with_bad_package_names(tmpdir): package_list = tmpdir.join('package-list') package_list.write('\n'.join(( '..', '/blah-2.tar.gz', 'lol-2.tar.gz/../', 'ocflib-2016.12.10.1.48-py2.py3-none-any.whl', '', ))) main.main(( '--package-list', package_list.strpath, '--output-dir', tmpdir.strpath, '--packages-url', '../../pool/', )) assert tmpdir.join('simple').check(dir=True) assert tmpdir.join('simple', 'index.html').check(file=True) assert tmpdir.join('simple', 'ocflib').check(dir=True) assert tmpdir.join('simple', 'ocflib', 'index.html').check(file=True)
def test_build_repo_json_smoke_test(tmpdir): package_list = tmpdir.join('package-list') _write_json_package_list( package_list, ( { 'filename': 'ocflib-2016.12.10.1.48-py2.py3-none-any.whl', 'uploaded_by': 'ckuehl', 'upload_timestamp': 1515783971, 'hash': 'md5=b1946ac92492d2347c6235b4d2611184', 'requires_python': '>=3.6', 'requires_dist': ['dumb-init', 'flask'], }, { 'filename': 'numpy-1.11.0rc1.tar.gz', 'upload_timestamp': 1515783971, }, { 'filename': 'scikit-learn-0.15.1.tar.gz', }, { # Version can't be parsed here but it's still allowed. 'filename': 'aspy.yaml.zip', }, ) ) main.main(( '--package-list-json', package_list.strpath, '--output-dir', tmpdir.strpath, '--packages-url', '../../pool/', )) assert tmpdir.join('simple').check(dir=True) assert tmpdir.join('simple', 'index.html').check(file=True) assert tmpdir.join('simple', 'ocflib').check(dir=True) assert tmpdir.join('simple', 'ocflib', 'index.html').check(file=True) assert tmpdir.join('pypi', 'ocflib', 'json').check(file=True) assert tmpdir.join('pypi', 'ocflib', '2016.12.10.1.48', 'json').check(file=True)
def test_build_repo_partial_rebuild(tmp_path): previous_packages = tmp_path / 'previous-packages' _write_json_package_list( previous_packages, ( {"filename": "a-0.0.1.tar.gz", "upload_timestamp": 1}, {"filename": "a-0.0.2.tar.gz", "upload_timestamp": 1}, {"filename": "b-0.0.1.tar.gz", "upload_timestamp": 1}, {"filename": "b-0.0.2.tar.gz", "upload_timestamp": 2}, {"filename": "c-0.0.1.tar.gz", "upload_timestamp": 1}, {"filename": "c-0.0.2.tar.gz", "upload_timestamp": 2}, ), ) packages = tmp_path / 'packages' _write_json_package_list( packages, ( # a is unchanged. {"filename": "a-0.0.1.tar.gz", "upload_timestamp": 1}, {"filename": "a-0.0.2.tar.gz", "upload_timestamp": 1}, # b has a new version. {"filename": "b-0.0.1.tar.gz", "upload_timestamp": 1}, {"filename": "b-0.0.2.tar.gz", "upload_timestamp": 2}, {"filename": "b-0.0.3.tar.gz", "upload_timestamp": 3}, # timestamp changed on c 0.0.2. {"filename": "c-0.0.1.tar.gz", "upload_timestamp": 1}, {"filename": "c-0.0.2.tar.gz", "upload_timestamp": 999}, # d is new. {"filename": "d-0.0.1.tar.gz", "upload_timestamp": 1}, ), ) main.main(( '--previous-package-list-json', str(previous_packages), '--package-list-json', str(packages), '--output-dir', str(tmp_path), '--packages-url', '../../pool/', )) assert (tmp_path / 'simple' / 'index.html').is_file() # a is unchanged. assert not (tmp_path / 'simple' / 'a').is_dir() assert not (tmp_path / 'pypi' / 'a').is_dir() # b has a new version. assert (tmp_path / 'simple' / 'b' / 'index.html').is_file() assert (tmp_path / 'pypi' / 'b' / 'json').is_file() assert (tmp_path / 'pypi' / 'b' / '0.0.3' / 'json').is_file() # timestamp changed on c 0.0.2. assert (tmp_path / 'simple' / 'c' / 'index.html').is_file() assert (tmp_path / 'pypi' / 'c' / 'json').is_file() # d is new. assert (tmp_path / 'simple' / 'd' / 'index.html').is_file() assert (tmp_path / 'pypi' / 'd' / 'json').is_file() assert (tmp_path / 'pypi' / 'd' / '0.0.1' / 'json').is_file() assert (tmp_path / 'index.html').is_file() assert (tmp_path / 'changelog').is_dir()