def test_get_all_packages(): # preconditions include_only = ['pip', 'pytest', 'faker'] tree = commands.get_package_tree(include_only=include_only) # action packages = commands.get_all_packages(tree=tree) # verification assert set(packages) == set(tree)
def test_get_required_package_version(): # preconditions include_only = ['pytest'] tree = commands.get_package_tree(include_only=include_only) packages = commands.get_all_packages(tree=tree) dist_package = list(tree.keys())[0] req_packages = packages[dist_package] # action and verification for package in req_packages: version = commands.get_required_package_version(package=package) assert version == (package.version_spec or VERSION_ANY)
def test_get_installed_package_version(): # preconditions include_only = ['pytest'] tree = commands.get_package_tree(include_only=include_only) packages = commands.get_all_packages(tree=tree) dist_package = list(packages.keys())[0] req_packages = packages[dist_package] # action and verification version = commands.get_installed_package_version(package=dist_package) assert version == dist_package.version for package in req_packages: version = commands.get_installed_package_version(package=package) assert version == package.installed_version
def test_package_list(): # preconditions include_only = ['pip', 'pytest', 'faker'] tree = commands.get_package_tree(include_only=include_only) packages = commands.get_all_packages(tree=tree) expected_packages = [{ 'name': package.key.lower(), 'version': commands.get_installed_package_version(package=package) } for package in list(packages.keys())] # action package_list = commands.get_package_list(tree=tree) # verification for expected_package in expected_packages: package = next((package for package in package_list if package['name'] == expected_package['name']), None) assert package['version'] == expected_package['version']