Commit c225114e authored by Léo-Paul Géneau's avatar Léo-Paul Géneau 👾 Committed by Kirill Smelkov

Store 'gem dependency' return value in files

Store return value of command 'gem dependency' in files rather than using a
dictionnary to use the same output as when the check_output method is not mocked

/reviewed-by @kirr
/reviewed-on !6
parent 96ddcde9
...@@ -162,7 +162,7 @@ class Recipe(object): ...@@ -162,7 +162,7 @@ class Recipe(object):
env.update({k: (v % env) for k, v in env_override}) env.update({k: (v % env) for k, v in env_override})
return env return env
def _get_gem_dict(self, gem_str): def get_gem_dict(self, gem_str):
parsed_gem = gem_str.split('==', 1) parsed_gem = gem_str.split('==', 1)
gem_dict = {'gemname': parsed_gem[0].strip()} gem_dict = {'gemname': parsed_gem[0].strip()}
if len(parsed_gem) > 1: if len(parsed_gem) > 1:
...@@ -326,7 +326,7 @@ class Recipe(object): ...@@ -326,7 +326,7 @@ class Recipe(object):
self._install_rubygems() self._install_rubygems()
gem_executable = self.get_gem_executable(bindir) gem_executable = self.get_gem_executable(bindir)
gem_dict_list = list(map(self._get_gem_dict, self.gems)) gem_dict_list = list(map(self.get_gem_dict, self.gems))
for gem_dict in gem_dict_list: for gem_dict in gem_dict_list:
if self.deployment: if self.deployment:
if 'version' not in gem_dict: if 'version' not in gem_dict:
......
Gem activesupport-3.2.0
i18n (~> 0.6)
multi_json (~> 1.0)
Gem cucumber-core-3.0.0
backports (>= 3.8.0)
bundler (>= 1.3.5, development)
coveralls (~> 0.7, development)
cucumber-tag_expressions (>= 1.0.1)
gherkin (>= 4.1.3)
kramdown (~> 1.4.2, development)
rake (>= 0.9.2, development)
rspec (~> 3, development)
unindent (>= 1.0, development)
yard (>= 0, development)
Gem cucumber-core-7.1.0
coveralls (>= 0.8.23, ~> 0.8, development)
cucumber-gherkin (>= 14.0.1, ~> 14.0)
cucumber-messages (>= 12.2.0, ~> 12.2)
cucumber-tag-expressions (>= 2.0.4, ~> 2.0)
rake (>= 13.0.0, ~> 13.0, development)
rspec (>= 3.9.0, ~> 3.9, development)
rubocop (>= 0.78.0, ~> 0.78, development)
unindent (>= 1.0, ~> 1.0, development)
Gem cucumber-gherkin-14.1.0
cucumber-messages (~> 12.3, >= 12.3.2)
rake (~> 13.0, >= 13.0.1, development)
rspec (~> 3.9, >= 3.9.0, development)
Gem cucumber-gherkin-9.1.0
coveralls (~> 0.8, >= 0.8.23, development)
cucumber-messages (~> 9.0, >= 9.0.3)
rake (~> 13.0, >= 13.0.1, development)
rspec (~> 3.9, >= 3.9.0, development)
Gem cucumber-messages-12.2.0
protobuf-cucumber (>= 3.10.8, ~> 3.10)
rake (>= 13.0.1, ~> 13.0, development)
rspec (>= 3.9.0, ~> 3.9, development)
Gem cucumber-messages-12.3.2
protobuf-cucumber (>= 3.10.8, ~> 3.10)
rake (>= 13.0.1, ~> 13.0, development)
rspec (>= 3.9.0, ~> 3.9, development)
Gem cucumber-messages-6.0.1
coveralls (>= 0.8.23, ~> 0.8, development)
google-protobuf (<= 3.8, >= 3.2)
rake (>= 13.0.0, ~> 13.0, development)
rspec (>= 3.8.0, ~> 3.8, development)
Gem cucumber-messages-9.0.2
coveralls (>= 0.8.23, ~> 0.8, development)
json (>= 2.3.0, ~> 2.3)
protobuf-cucumber (>= 3.10.4, ~> 3.10)
rake (>= 13.0.1, ~> 13.0, development)
rspec (>= 3.9.0, ~> 3.9, development)
Gem cucumber-messages-9.0.3
coveralls (>= 0.8.23, ~> 0.8, development)
json (>= 2.3.0, ~> 2.3)
protobuf-cucumber (>= 3.10.4, ~> 3.10)
rake (>= 13.0.1, ~> 13.0, development)
rspec (>= 3.9.0, ~> 3.9, development)
Gem cucumber-tag-expressions-2.0.4
coveralls (>= 0.8.23, ~> 0.8, development)
rake (>= 13.0.1, ~> 13.0, development)
rspec (>= 3.9.0, ~> 3.9, development)
Gem cucumber-tag_expressions-1.0.1
bundler (>= 0, development)
coveralls (>= 0, development)
rake (~> 10.5, development)
rspec (~> 3.5, development)
Gem gherkin-8.0.0
coveralls (>= 0.8.23, ~> 0.8, development)
cucumber-messages (~> 6.0, >= 6.0.1)
rake (>= 13.0.0, ~> 13.0, development)
rspec (>= 3.8.0, ~> 3.8, development)
Gem google-protobuf-3.2.0
rake-compiler (~> 0.9.5, development)
rake-compiler-dock (~> 0.6.0, development)
rubygems-tasks (~> 0.2.4, development)
test-unit (>= 3.0.9, ~> 3.0, development)
Gem google-protobuf-3.2.0-x86_64-linux
rake-compiler (~> 0.9.5, development)
rake-compiler-dock (~> 0.6.0, development)
rubygems-tasks (~> 0.2.4, development)
test-unit (>= 3.0.9, ~> 3.0, development)
Gem hashie-0.3.1
rspec (>= 0, development)
Gem hashie-1.0.0
rspec (>= 0, development)
Gem hoe-3.4.0
minitest (~> 4.3, development)
rake (< 11.0, >= 0.8)
rdoc (~> 3.10, development)
Gem i18n-0.6.0
activesupport (~> 3.0.0, development)
mocha (>= 0, development)
sqlite3 (>= 0, development)
test_declarative (>= 0, development)
Gem json-2.3.0
rake (>= 0, development)
test-unit (~> 2.0, development)
Gem middleware-0.1.0
rake (>= 0, development)
redcarpet (~> 2.1.0, development)
rspec-core (~> 2.8.0, development)
rspec-expectations (~> 2.8.0, development)
rspec-mocks (~> 2.8.0, development)
yard (~> 0.7.5, development)
Gem protobuf-cucumber-3.10.8
activesupport (>= 3.2)
benchmark-ips (>= 0, development)
ffi-rzmq (>= 0, development)
middleware (>= 0)
parser (= 2.3.0.6, development)
pry-byebug (>= 0, development)
pry-stack_explorer (>= 0, development)
rake (< 11.0, development)
rspec (>= 3.0, development)
rubocop (~> 0.38.0, development)
ruby-prof (>= 0, development)
simplecov (>= 0, development)
thor (>= 0)
thread_safe (>= 0)
timecop (>= 0, development)
varint (>= 0, development)
yard (>= 0, development)
Gem rake-10.0.1
minitest (~> 2.1, development)
Gem rash-0.1.0
hashie (>= 0.3.1)
rspec (>= 1.2.9, development)
Gem rash-0.3.0
hashie (~> 1.0.0)
rspec (~> 2.5.0, development)
Gem thread_safe-0.1.0
atomic (>= 0)
...@@ -22,191 +22,6 @@ def touch(path): ...@@ -22,191 +22,6 @@ def touch(path):
with path.open('w') as f: with path.open('w') as f:
f.write('') f.write('')
gem_dependencies = {
'cucumber-core': {
'3.0.0': [
{
'gemname': 'backports',
'constraint_list': [
{
'symbol': '>=',
'version': '3.8.0',
},
{
'symbol': '',
'version': '',
},
]
},
{
'gemname': 'cucumber-tag_expressions',
'constraint_list': [
{
'symbol': '>=',
'version': '1.0.1',
},
{
'symbol': '',
'version': '',
},
]
},
{
'gemname': 'gherkin',
'constraint_list': [
{
'symbol': '>=',
'version': '4.1.3',
},
{
'symbol': '',
'version': '',
},
]
},
],
'7.1.0': [
{
'gemname': 'cucumber-gherkin',
'constraint_list': [
{
'symbol': '~>',
'version': '14.0',
},
{
'symbol': '>=',
'version': '14.0.1',
},
]
},
{
'gemname': 'cucumber-messages',
'constraint_list': [
{
'symbol': '>=',
'version': '12.2.0',
},
{
'symbol': '~>',
'version': '12.2',
},
]
},
{
'gemname': 'cucumber-tag_expressions',
'constraint_list': [
{
'symbol': '~>',
'version': '2.0',
},
{
'symbol': '>=',
'version': '2.0.4',
},
]
},
],
},
'cucumber-gherkin': {
'9.1.0': [
{
'gemname': 'cucumber-messages',
'constraint_list': [
{
'symbol': '~>',
'version': '9.0',
},
{
'symbol': '>=',
'version': '9.0.3',
},
]
},
],
'14.1.0': [
{
'gemname': 'cucumber-messages',
'constraint_list': [
{
'symbol': '~>',
'version': '12.3',
},
{
'symbol': '>=',
'version': '12.3.2',
},
]
},
],
},
'gherkin': {
'8.0.0': [
{
'gemname': 'cucumber-messages',
'constraint_list': [
{
'symbol': '~>',
'version': '6.0',
},
{
'symbol': '>=',
'version': '6.0.1',
},
]
},
],
},
'hoe': {
'3.4.0': [
{
'gemname': 'rake',
'constraint_list': [
{
'symbol': '<',
'version': '11.0',
},
{
'symbol': '>=',
'version': '0.8',
},
]
},
],
},
'rash': {
'0.1.0': [
{
'gemname': 'hashie',
'constraint_list': [
{
'symbol': '>=',
'version': '0.3.1',
},
{
'symbol': '',
'version': '',
},
]
},
],
'0.3.0': [
{
'gemname': 'hashie',
'constraint_list': [
{
'symbol': '~>',
'version': '1.0.0',
},
{
'symbol': '',
'version': '',
},
]
},
],
},
}
class fixture(object): class fixture(object):
def __init__(self, options=None, version='2.0.0'): def __init__(self, options=None, version='2.0.0'):
...@@ -304,6 +119,8 @@ class RubyGemsTestCase(unittest.TestCase): ...@@ -304,6 +119,8 @@ class RubyGemsTestCase(unittest.TestCase):
self.check_output_test( self.check_output_test(
patches['check_output'], expected_install_arg_list_list) patches['check_output'], expected_install_arg_list_list)
class RubyGemsDefaultTestCase(RubyGemsTestCase):
@fixture({'recipe': {'gems': 'sass'}}) @fixture({'recipe': {'gems': 'sass'}})
def test_success(self, path, patches, buildout, name, options): def test_success(self, path, patches, buildout, name, options):
recipe = rubygems.Recipe(buildout, name, options) recipe = rubygems.Recipe(buildout, name, options)
...@@ -440,7 +257,48 @@ class RubyGemsTestCase(unittest.TestCase): ...@@ -440,7 +257,48 @@ class RubyGemsTestCase(unittest.TestCase):
recipe = rubygems.Recipe(buildout, name, options) recipe = rubygems.Recipe(buildout, name, options)
recipe.install() recipe.install()
@fixture({'recipe': {'gems': 'sass', 'deployment': 'true'}}) class deployment_fixture(fixture):
def mocked_check_output_for_dependencies(self, cmd, **kwargs):
if len(cmd) > 3 and cmd[2] == 'dependency':
filename = 'dependency_%s-%s.txt' % (cmd[5][2:-2], cmd[4])
dependency_output_file = os.path.join(
os.path.dirname(os.path.realpath(__file__)), 'test_data', filename)
with open(dependency_output_file) as fd:
dependency_output = fd.read()
return dependency_output
def set_up(self):
buildout, name, options = super(deployment_fixture, self).set_up()
options['deployment'] = 'true'
self.patches['check_output'].side_effect = self.mocked_check_output_for_dependencies
return buildout, name, options
class RubyGemsDeploymentTestCase(RubyGemsTestCase):
def deployment_install_test(self, buildout, name, path, patches, options):
recipe = rubygems.Recipe(buildout, name, options)
recipe.install()
expected_install_arg_list_list = []
gem_dict_list = list(map(recipe.get_gem_dict, recipe.gems))
for gem_dict in gem_dict_list:
expected_install_arg_list_list.extend([
[
'ruby', None, 'dependency', '-rv', gem_dict['version'],
'/^%s$/' % gem_dict['gemname'].replace('.',r'\.'),
], [
'ruby', None, 'install', '--no-document',
'--bindir=%s/rubygems/bin' % path,
'--ignore-dependencies', gem_dict['gemname'],
'--version=' + gem_dict['version'], '--',
]
])
self.install_with_default_rubygems_test(
path, patches, expected_install_arg_list_list)
@deployment_fixture({'recipe': {'gems': 'sass'}})
def test_deployment_not_pinned_version_error( def test_deployment_not_pinned_version_error(
self, path, patches, buildout, name, options): self, path, patches, buildout, name, options):
recipe = rubygems.Recipe(buildout, name, options) recipe = rubygems.Recipe(buildout, name, options)
...@@ -450,11 +308,9 @@ class RubyGemsTestCase(unittest.TestCase): ...@@ -450,11 +308,9 @@ class RubyGemsTestCase(unittest.TestCase):
recipe.install recipe.install
) )
@fixture({'recipe': {'gems': 'rash==0.1.0', 'deployment': 'true'}}) @deployment_fixture({'recipe': {'gems': 'rash==0.1.0'}})
@mock.patch('rubygems.Recipe.get_dependency_list')
def test_deployment_not_pinned_dependency_error( def test_deployment_not_pinned_dependency_error(
self, path, patches, buildout, name, options, get_dependency_list): self, path, patches, buildout, name, options):
get_dependency_list.side_effect = [gem_dependencies['rash']['0.1.0']]
recipe = rubygems.Recipe(buildout, name, options) recipe = rubygems.Recipe(buildout, name, options)
self.assertRaisesRegexp( self.assertRaisesRegexp(
zc.buildout.UserError, zc.buildout.UserError,
...@@ -462,14 +318,9 @@ class RubyGemsTestCase(unittest.TestCase): ...@@ -462,14 +318,9 @@ class RubyGemsTestCase(unittest.TestCase):
recipe.install recipe.install
) )
@fixture({'recipe': { @deployment_fixture({'recipe': {'gems': 'rash==0.1.0 hashie==0.3.0'}})
'gems': 'rash==0.1.0 hashie==0.3.0', def test_deployment_more_or_equal_constraint_error(
'deployment': 'true' self, path, patches, buildout, name, options):
}})
@mock.patch('rubygems.Recipe.get_dependency_list')
def test_deployment_rash010_version_dependency_error(
self, path, patches, buildout, name, options, get_dependency_list):
get_dependency_list.side_effect = [gem_dependencies['rash']['0.1.0']]
recipe = rubygems.Recipe(buildout, name, options) recipe = rubygems.Recipe(buildout, name, options)
self.assertRaisesRegexp( self.assertRaisesRegexp(
zc.buildout.UserError, zc.buildout.UserError,
...@@ -478,41 +329,14 @@ class RubyGemsTestCase(unittest.TestCase): ...@@ -478,41 +329,14 @@ class RubyGemsTestCase(unittest.TestCase):
recipe.install recipe.install
) )
@fixture({'recipe': { @deployment_fixture({'recipe': {'gems': 'rash==0.1.0 hashie==0.3.1'}})
'gems': 'rash==0.1.0 hashie==0.3.1', def test_deployment_more_or_equal_constraint_success(
'deployment': 'true' self, path, patches, buildout, name, options):
}}) self.deployment_install_test(buildout, name, path, patches, options)
@mock.patch('rubygems.Recipe.get_dependency_list')
def test_deployment_rash010_pinned_dependency(
self, path, patches, buildout, name, options, get_dependency_list):
get_dependency_list.side_effect = [gem_dependencies['rash']['0.1.0'],
[],]
recipe = rubygems.Recipe(buildout, name, options)
recipe.install()
expected_install_arg_list_list = [
[
'ruby', None, 'install', '--no-document',
'--bindir=%s/rubygems/bin' % path,
'--ignore-dependencies', 'rash', '--version=0.1.0', '--',
],
[
'ruby', None, 'install', '--no-document',
'--bindir=%s/rubygems/bin' % path,
'--ignore-dependencies', 'hashie', '--version=0.3.1', '--',
],
]
self.install_with_default_rubygems_test(
path, patches, expected_install_arg_list_list)
@fixture({'recipe': { @deployment_fixture({'recipe': {'gems': 'rash==0.3.0 hashie==1.1.0'}})
'gems': 'rash==0.3.0 hashie==1.1.0', def test_deployment_similar_constraint_error(
'deployment': 'true' self, path, patches, buildout, name, options):
}})
@mock.patch('rubygems.Recipe.get_dependency_list')
def test_deployment_rash030_version_dependency_error(
self, path, patches, buildout, name, options, get_dependency_list):
get_dependency_list.side_effect = [gem_dependencies['rash']['0.3.0']]
recipe = rubygems.Recipe(buildout, name, options) recipe = rubygems.Recipe(buildout, name, options)
self.assertRaisesRegexp( self.assertRaisesRegexp(
zc.buildout.UserError, zc.buildout.UserError,
...@@ -521,42 +345,19 @@ class RubyGemsTestCase(unittest.TestCase): ...@@ -521,42 +345,19 @@ class RubyGemsTestCase(unittest.TestCase):
recipe.install recipe.install
) )
@fixture({'recipe': { @deployment_fixture({'recipe': {'gems': 'rash==0.3.0 hashie==1.0.0'}})
'gems': 'rash==0.3.0 hashie==1.0.0', def test_deployment_similar_constraint_success(
'deployment': 'true' self, path, patches, buildout, name, options):
}}) self.deployment_install_test(buildout, name, path, patches, options)
@mock.patch('rubygems.Recipe.get_dependency_list')
def test_deployment_rash030_pinned_dependency(
self, path, patches, buildout, name, options, get_dependency_list):
get_dependency_list.side_effect = [gem_dependencies['rash']['0.3.0'],
[],]
recipe = rubygems.Recipe(buildout, name, options)
recipe.install()
expected_install_arg_list_list = [
[
'ruby', None, 'install', '--no-document',
'--bindir=%s/rubygems/bin' % path,
'--ignore-dependencies', 'rash', '--version=0.3.0', '--',
],
[
'ruby', None, 'install', '--no-document',
'--bindir=%s/rubygems/bin' % path,
'--ignore-dependencies', 'hashie', '--version=1.0.0', '--',
],
]
self.install_with_default_rubygems_test(
path, patches, expected_install_arg_list_list)
@fixture({'recipe': { @deployment_fixture({'recipe': {
'gems': 'cucumber-gherkin==9.1.0 cucumber-messages==9.0.2', 'gems': 'activesupport==3.2.0 atomic==0.0.1 cucumber-gherkin==9.1.0 '
'deployment': 'true' 'cucumber-messages==9.0.2 i18n==0.6.0 json==2.3.0 '
'middleware==0.1.0 multi_json==1.0.0 protobuf-cucumber==3.10.8 '
'thor==0.9.2 thread_safe==0.1.0'
}}) }})
@mock.patch('rubygems.Recipe.get_dependency_list') def test_deployment_more_or_equal_constraint_error(
def test_deployment_cucumber_gherkin_version_dependency_error( self, path, patches, buildout, name, options):
self, path, patches, buildout, name, options, get_dependency_list):
get_dependency_list.side_effect = [
gem_dependencies['cucumber-gherkin']['9.1.0']]
recipe = rubygems.Recipe(buildout, name, options) recipe = rubygems.Recipe(buildout, name, options)
self.assertRaisesRegexp( self.assertRaisesRegexp(
zc.buildout.UserError, zc.buildout.UserError,
...@@ -566,43 +367,19 @@ class RubyGemsTestCase(unittest.TestCase): ...@@ -566,43 +367,19 @@ class RubyGemsTestCase(unittest.TestCase):
recipe.install recipe.install
) )
@fixture({'recipe': { @deployment_fixture({'recipe': {
'gems': 'cucumber-gherkin==9.1.0 cucumber-messages==9.0.3', 'gems': 'activesupport==3.2.0 atomic==0.0.1 cucumber-gherkin==9.1.0 '
'deployment': 'true' 'cucumber-messages==9.0.3 i18n==0.6.0 json==2.3.0 '
'middleware==0.1.0 multi_json==1.0.0 protobuf-cucumber==3.10.8 '
'thor==0.9.2 thread_safe==0.1.0'
}}) }})
@mock.patch('rubygems.Recipe.get_dependency_list') def test_deployment_more_or_equal_constraint_success(
def test_deployment_cucumber_gherkin_pinned_dependency( self, path, patches, buildout, name, options):
self, path, patches, buildout, name, options, get_dependency_list): self.deployment_install_test(buildout, name, path, patches, options)
get_dependency_list.side_effect = [
gem_dependencies['cucumber-gherkin']['9.1.0'], []]
recipe = rubygems.Recipe(buildout, name, options)
recipe.install()
expected_install_arg_list_list = [
[
'ruby', None, 'install', '--no-document',
'--bindir=%s/rubygems/bin' % path,
'--ignore-dependencies', 'cucumber-gherkin',
'--version=9.1.0', '--',
],
[
'ruby', None, 'install', '--no-document',
'--bindir=%s/rubygems/bin' % path,
'--ignore-dependencies', 'cucumber-messages',
'--version=9.0.3', '--',
],
]
self.install_with_default_rubygems_test(
path, patches, expected_install_arg_list_list)
@fixture({'recipe': { @deployment_fixture({'recipe': {'gems': 'hoe==3.4.0 rake==11.0.0'}})
'gems': 'hoe==3.4.0 rake==11.0.0', def test_deployment_less_constraint_error(
'deployment': 'true' self, path, patches, buildout, name, options):
}})
@mock.patch('rubygems.Recipe.get_dependency_list')
def test_deployment_hoe_version_dependency_error(
self, path, patches, buildout, name, options, get_dependency_list):
get_dependency_list.side_effect = [gem_dependencies['hoe']['3.4.0']]
recipe = rubygems.Recipe(buildout, name, options) recipe = rubygems.Recipe(buildout, name, options)
self.assertRaisesRegexp( self.assertRaisesRegexp(
zc.buildout.UserError, zc.buildout.UserError,
...@@ -611,45 +388,17 @@ class RubyGemsTestCase(unittest.TestCase): ...@@ -611,45 +388,17 @@ class RubyGemsTestCase(unittest.TestCase):
recipe.install recipe.install
) )
@fixture({'recipe': { @deployment_fixture({'recipe': {'gems': 'hoe==3.4.0 rake==10.0.1'}})
'gems': 'hoe==3.4.0 rake==10.0.1', def test_deployment_less_constraint_success(
'deployment': 'true' self, path, patches, buildout, name, options):
}}) self.deployment_install_test(buildout, name, path, patches, options)
@mock.patch('rubygems.Recipe.get_dependency_list')
def test_deployment_hoe_pinned_dependency(
self, path, patches, buildout, name, options, get_dependency_list):
get_dependency_list.side_effect = [
gem_dependencies['hoe']['3.4.0'], []]
recipe = rubygems.Recipe(buildout, name, options)
recipe.install()
expected_install_arg_list_list = [
[
'ruby', None, 'install', '--no-document',
'--bindir=%s/rubygems/bin' % path,
'--ignore-dependencies', 'hoe', '--version=3.4.0', '--',
],
[
'ruby', None, 'install', '--no-document',
'--bindir=%s/rubygems/bin' % path,
'--ignore-dependencies', 'rake', '--version=10.0.1', '--',
],
]
self.install_with_default_rubygems_test(
path, patches, expected_install_arg_list_list)
@fixture({'recipe': { @deployment_fixture({'recipe': {
'gems': 'cucumber-core==3.0.0 backports==3.8.0 ' 'gems': 'cucumber-core==3.0.0 backports==3.8.0 '
'cucumber-tag_expressions==1.0.1 gherkin==8.0.0', 'cucumber-tag_expressions==1.0.1 gherkin==8.0.0'
'deployment': 'true'
}}) }})
@mock.patch('rubygems.Recipe.get_dependency_list') def test_deployment_not_pinned_subdependency_error(
def test_deployment_cucumber_core300_version_dependency_error( self, path, patches, buildout, name, options):
self, path, patches, buildout, name, options, get_dependency_list):
get_dependency_list.side_effect = [
gem_dependencies['cucumber-core']['3.0.0'], [], [],
gem_dependencies['gherkin']['8.0.0'],
]
recipe = rubygems.Recipe(buildout, name, options) recipe = rubygems.Recipe(buildout, name, options)
self.assertRaisesRegexp( self.assertRaisesRegexp(
zc.buildout.UserError, zc.buildout.UserError,
...@@ -658,69 +407,24 @@ class RubyGemsTestCase(unittest.TestCase): ...@@ -658,69 +407,24 @@ class RubyGemsTestCase(unittest.TestCase):
recipe.install recipe.install
) )
@fixture({'recipe': { @deployment_fixture({'recipe': {
'gems': 'cucumber-core==3.0.0 backports==3.8.0 ' 'gems': 'cucumber-core==3.0.0 backports==3.8.0 '
'cucumber-tag_expressions==1.0.1 gherkin==8.0.0 ' 'cucumber-tag_expressions==1.0.1 gherkin==8.0.0 '
'cucumber-messages==6.0.1', 'cucumber-messages==6.0.1'
'deployment': 'true'
}}) }})
@mock.patch('rubygems.Recipe.get_dependency_list') def test_deployment_pinned_subdependency_success(
def test_deployment_cucumber_core300_pinnned_dependency( self, path, patches, buildout, name, options):
self, path, patches, buildout, name, options, get_dependency_list): self.deployment_install_test(buildout, name, path, patches, options)
get_dependency_list.side_effect = [
gem_dependencies['cucumber-core']['3.0.0'], [], [], @deployment_fixture({'recipe': {
gem_dependencies['gherkin']['8.0.0'], [], 'gems': 'activesupport==3.2.0 atomic==0.0.1 cucumber-core==7.1.0 '
] 'cucumber-messages==12.2.0 cucumber-gherkin==14.1.0 '
recipe = rubygems.Recipe(buildout, name, options) 'cucumber-tag-expressions==2.0.4 i18n==0.6.0 middleware==0.1.0 '
recipe.install() 'multi_json==1.0.0 protobuf-cucumber==3.10.8 thor==0.9.2 '
'thread_safe==0.1.0'
expected_install_arg_list_list = [
[
'ruby', None, 'install', '--no-document',
'--bindir=%s/rubygems/bin' % path,
'--ignore-dependencies', 'cucumber-core',
'--version=3.0.0', '--',
],
[
'ruby', None, 'install', '--no-document',
'--bindir=%s/rubygems/bin' % path,
'--ignore-dependencies', 'backports',
'--version=3.8.0', '--',
],
[
'ruby', None, 'install', '--no-document',
'--bindir=%s/rubygems/bin' % path,
'--ignore-dependencies', 'cucumber-tag_expressions',
'--version=1.0.1', '--',
],
[
'ruby', None, 'install', '--no-document',
'--bindir=%s/rubygems/bin' % path,
'--ignore-dependencies', 'gherkin',
'--version=8.0.0', '--',
],
[
'ruby', None, 'install', '--no-document',
'--bindir=%s/rubygems/bin' % path,
'--ignore-dependencies', 'cucumber-messages',
'--version=6.0.1', '--',
],
]
self.install_with_default_rubygems_test(
path, patches, expected_install_arg_list_list)
@fixture({'recipe': {
'gems': 'cucumber-core==7.1.0 cucumber-messages==12.2.0 '
'cucumber-gherkin==14.1.0 cucumber-tag_expressions==2.0.4',
'deployment': 'true'
}}) }})
@mock.patch('rubygems.Recipe.get_dependency_list') def test_deployment_subdependency_constraint_error(
def test_deployment_cucumber_core710_version_dependency_error( self, path, patches, buildout, name, options):
self, path, patches, buildout, name, options, get_dependency_list):
get_dependency_list.side_effect = [
gem_dependencies['cucumber-core']['7.1.0'], [],
gem_dependencies['cucumber-gherkin']['14.1.0'], [],
]
recipe = rubygems.Recipe(buildout, name, options) recipe = rubygems.Recipe(buildout, name, options)
self.assertRaisesRegexp( self.assertRaisesRegexp(
zc.buildout.UserError, zc.buildout.UserError,
...@@ -730,46 +434,13 @@ class RubyGemsTestCase(unittest.TestCase): ...@@ -730,46 +434,13 @@ class RubyGemsTestCase(unittest.TestCase):
recipe.install recipe.install
) )
@fixture({'recipe': { @deployment_fixture({'recipe': {
'gems': 'cucumber-core==7.1.0 cucumber-messages==12.3.2 ' 'gems': 'activesupport==3.2.0 atomic==0.0.1 cucumber-core==7.1.0 '
'cucumber-gherkin==14.1.0 cucumber-tag_expressions==2.0.4', 'cucumber-messages==12.3.2 cucumber-gherkin==14.1.0 '
'deployment': 'true' 'cucumber-tag-expressions==2.0.4 i18n==0.6.0 middleware==0.1.0 '
'multi_json==1.0.0 protobuf-cucumber==3.10.8 thor==0.9.2 '
'thread_safe==0.1.0'
}}) }})
@mock.patch('rubygems.Recipe.get_dependency_list') def test_deployment_subdependency_constraint_success(
def test_deployment_cucumber_core710_pinned_dependency( self, path, patches, buildout, name, options):
self, path, patches, buildout, name, options, get_dependency_list): self.deployment_install_test(buildout, name, path, patches, options)
get_dependency_list.side_effect = [
gem_dependencies['cucumber-core']['7.1.0'], [],
gem_dependencies['cucumber-gherkin']['14.1.0'], [],
]
recipe = rubygems.Recipe(buildout, name, options)
recipe.install()
expected_install_arg_list_list = [
[
'ruby', None, 'install', '--no-document',
'--bindir=%s/rubygems/bin' % path,
'--ignore-dependencies', 'cucumber-core',
'--version=7.1.0', '--',
],
[
'ruby', None, 'install', '--no-document',
'--bindir=%s/rubygems/bin' % path,
'--ignore-dependencies', 'cucumber-messages',
'--version=12.3.2', '--',
],
[
'ruby', None, 'install', '--no-document',
'--bindir=%s/rubygems/bin' % path,
'--ignore-dependencies', 'cucumber-gherkin',
'--version=14.1.0', '--',
],
[
'ruby', None, 'install', '--no-document',
'--bindir=%s/rubygems/bin' % path,
'--ignore-dependencies', 'cucumber-tag_expressions',
'--version=2.0.4', '--',
],
]
self.install_with_default_rubygems_test(
path, patches, expected_install_arg_list_list)
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment