def test_resolve_specific_python(mocker, command): resolve = mocker.patch('piptools.resolver.Resolver.resolve') reverse_dependencies = mocker.patch( 'piptools.resolver.Resolver.reverse_dependencies') resolve_hashes = mocker.patch('piptools.resolver.Resolver.resolve_hashes') resolve.return_value = [ pendulum_req, pytzdata_req, requests_req, ] reverse_dependencies.return_value = {'pytzdata': set(['pendulum'])} resolve_hashes.return_value = { pendulum_req: set(pendulum_hashes), requests_req: set(requests_hashes), pytzdata_req: set(pytzdata_hashes), } installer = Installer(command, PyPiRepository()) packages = installer._resolve([ PipDependency('pendulum', '^1.2'), PipDependency('requests', { 'version': '^2.13', 'python': '~2.7' }) ]) pendulum = packages[0] pytzdata = packages[1] requests = packages[2] # Name assert 'pendulum' == pendulum['name'] assert 'pytzdata' == pytzdata['name'] assert 'requests' == requests['name'] # Version assert '1.2.0' == pendulum['version'] assert '2017.2' == pytzdata['version'] assert '2.13.0' == requests['version'] # Version assert set(pendulum_hashes) == set(pendulum['checksum']) assert set(pytzdata_hashes) == set(pytzdata['checksum']) assert set(requests_hashes) == set(requests['checksum']) # Category assert 'main' == pendulum['category'] assert 'main' == pytzdata['category'] assert 'main' == requests['category'] # Optional assert not pendulum['optional'] assert not pytzdata['optional'] assert not requests['optional'] # Python assert ['*'] == pendulum['python'] assert ['*'] == pytzdata['python'] assert ['~2.7'] == requests['python']
def test_resolve_update_actions_upgrade(command): installer = Installer(command, PyPiRepository()) current_deps = [foo_dependency_123, bar_dependency_321] deps = [foo_dependency_133, PipDependency('bar', '3.2.1')] actions = installer._resolve_update_actions(deps, current_deps) expected = [('update', foo_dependency_123, foo_dependency_133)] assert expected == actions
def test_resolve_update_actions_remove(command): installer = Installer(command, PyPiRepository()) current_deps = [foo_dependency_123, bar_dependency_321] deps = [foo_dependency_123] actions = installer._resolve_update_actions(deps, current_deps) expected = [('remove', None, bar_dependency_321)] assert expected == actions
def test_resolve_update_actions_up_to_date(command): installer = Installer(command, PyPiRepository()) current_deps = [ PipDependency('foo', '1.2.3'), PipDependency('bar', '3.2.1') ] deps = [PipDependency('foo', '1.2.3'), PipDependency('bar', '3.2.1')] actions = installer._resolve_update_actions(deps, current_deps) assert [] == actions