def test_update_all_packages_with_ignorelist(monkeypatch): """Test calling update_all_packages()""" public_pkg_1 = PkgFile("Flask", "1.0") public_pkg_2 = PkgFile("requests", "1.0") private_pkg_1 = PkgFile("my_private_pkg", "1.0") private_pkg_2 = PkgFile("my_other_private_pkg", "1.0") roots_mock = { "/opt/pypi": [ public_pkg_1, private_pkg_1, ], "/data/pypi": [public_pkg_2, private_pkg_2], } def core_listdir_mock(directory): return roots_mock.get(directory, []) monkeypatch.setattr(manage.core, "listdir", core_listdir_mock) monkeypatch.setattr(manage, "update", Mock(return_value=None)) destdir = None dry_run = False stable_only = True update_all_packages( roots=list(roots_mock.keys()), destdir=destdir, dry_run=dry_run, stable_only=stable_only, ignorelist=["my_private_pkg", "my_other_private_pkg"], ) manage.update.assert_called_once_with( # pylint: disable=no-member frozenset([public_pkg_1, public_pkg_2]), destdir, dry_run, stable_only)
def pkgfile_from_path(fn): pkgname, version = guess_pkgname_and_version(fn) return PkgFile( pkgname=pkgname, version=version, root=py.path.local(fn).parts()[1].strpath, # noqa pylint: disable=no-member fn=fn)
def test_update_package(monkeypatch): """Test generating an update command for a package.""" monkeypatch.setattr(manage, 'call', Mock()) pkg = PkgFile('mypkg', '1.0', replaces=PkgFile('mypkg', '0.9')) update_package(pkg, '.') manage.call.assert_called_once_with(( # pylint: disable=no-member 'pip', '-q', 'download', '--no-deps', '-i', 'https://pypi.org/simple', '-d', '.', 'mypkg==1.0', ))
def test_update_package(monkeypatch): """Test generating an update command for a package.""" monkeypatch.setattr(manage, "call", Mock()) pkg = PkgFile("mypkg", "1.0", replaces=PkgFile("mypkg", "0.9")) update_package(pkg, ".") manage.call.assert_called_once_with(( # pylint: disable=no-member "pip", "-q", "download", "--no-deps", "-i", "https://pypi.org/simple", "-d", ".", "mypkg==1.0", ))
def pkgfile_from_path(fn): pkgname, version = guess_pkgname_and_version(fn) return PkgFile(root=py.path.local(fn).parts()[1].strpath, fn=fn, pkgname=pkgname, version=version, parsed_version=parse_version(version))
def test_update_all_packages_with_blacklist(monkeypatch): """Test calling update_all_packages()""" public_pkg_1 = PkgFile('Flask', '1.0') public_pkg_2 = PkgFile('requests', '1.0') private_pkg_1 = PkgFile('my_private_pkg', '1.0') private_pkg_2 = PkgFile('my_other_private_pkg', '1.0') roots_mock = { '/opt/pypi': [ public_pkg_1, private_pkg_1, ], '/data/pypi': [public_pkg_2, private_pkg_2], } def core_listdir_mock(directory): return roots_mock.get(directory, []) monkeypatch.setattr(manage.core, 'listdir', core_listdir_mock) monkeypatch.setattr( manage.core, 'read_lines', Mock(return_value=['my_private_pkg', 'my_other_private_pkg'])) monkeypatch.setattr(manage, 'update', Mock(return_value=None)) destdir = None dry_run = False stable_only = True blacklist_file = '/root/pkg_blacklist' update_all_packages( roots=list(roots_mock.keys()), destdir=destdir, dry_run=dry_run, stable_only=stable_only, blacklist_file=blacklist_file, ) manage.update.assert_called_once_with( # pylint: disable=no-member frozenset([public_pkg_1, public_pkg_2]), destdir, dry_run, stable_only) manage.core.read_lines.assert_called_once_with(blacklist_file) # pylint: disable=no-member
def test_update_package_dry_run(monkeypatch): """Test generating an update command for a package.""" monkeypatch.setattr(manage, 'call', Mock()) pkg = PkgFile('mypkg', '1.0', replaces=PkgFile('mypkg', '0.9')) update_package(pkg, '.', dry_run=True) assert not manage.call.mock_calls # pylint: disable=no-member
def test_update_package_dry_run(monkeypatch): """Test generating an update command for a package.""" monkeypatch.setattr(manage, "call", Mock()) pkg = PkgFile("mypkg", "1.0", replaces=PkgFile("mypkg", "0.9")) update_package(pkg, ".", dry_run=True) assert not manage.call.mock_calls # pylint: disable=no-member