File tree 8 files changed +61
-6
lines changed
test/cookbooks/python_test
files/default/tests/minitest
8 files changed +61
-6
lines changed Original file line number Diff line number Diff line change @@ -35,20 +35,23 @@ platforms:
35
35
suites :
36
36
- name : default
37
37
run_list :
38
+ - recipe[minitest-handler]
38
39
- recipe[python]
40
+ - recipe[python_test::cook-3084]
39
41
attributes : {}
40
42
41
43
- name : source
42
44
run_list :
45
+ - recipe[minitest-handler]
43
46
- recipe[python]
47
+ - recipe[python_test::cook-3084]
44
48
attributes : {python: {install_method: "source"}}
45
49
- name : exert
46
50
excludes : ["centos-5.9"]
47
51
run_list :
48
52
- recipe[python]
49
53
- recipe[python_test::test_exert]
50
54
- name : virtualenv
51
- excludes : ["centos-5.9"]
52
55
run_list :
53
56
- recipe[python]
54
57
- recipe[python_test::test_virtualenv]
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ site :opscode
3
3
metadata
4
4
5
5
group :integration do
6
+ cookbook "minitest-handler"
6
7
cookbook "apt"
7
8
cookbook "yum"
8
9
cookbook "build-essential"
Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ Install packages using the new hotness in Python package management...[`pip`](ht
95
95
# Attribute Parameters
96
96
97
97
- path: name attribute. The path where the virtualenv will be created
98
- - interpreter: The Python interpreter to use. default is ` python2.6 `
98
+ - interpreter: The Python interpreter to use. default is null (i.e. use whatever python the virtualenv command is using).
99
99
- owner: The owner for the virtualenv
100
100
- group: The group owner of the file (string or id)
101
101
- options : Command line options (string)
Original file line number Diff line number Diff line change @@ -29,7 +29,8 @@ def whyrun_supported?
29
29
action :create do
30
30
unless exists?
31
31
Chef ::Log . info ( "Creating virtualenv #{ new_resource } at #{ new_resource . path } " )
32
- execute "#{ virtualenv_cmd } --python=#{ new_resource . interpreter } #{ new_resource . options } #{ new_resource . path } " do
32
+ interpreter = new_resource . interpreter ? " --python=#{ new_resource . interpreter } " : ""
33
+ execute "#{ virtualenv_cmd } #{ interpreter } #{ new_resource . options } #{ new_resource . path } " do
33
34
user new_resource . owner if new_resource . owner
34
35
group new_resource . group if new_resource . group
35
36
end
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ def initialize(*args)
28
28
end
29
29
30
30
attribute :path , :kind_of => String , :name_attribute => true
31
- attribute :interpreter , :default => 'python'
31
+ attribute :interpreter , :kind_of => String
32
32
attribute :owner , :regex => Chef ::Config [ :user_valid_regex ]
33
33
attribute :group , :regex => Chef ::Config [ :group_valid_regex ]
34
34
attribute :options , :kind_of => String
Original file line number Diff line number Diff line change
1
+ require 'minitest/spec'
2
+
3
+ describe_recipe 'python_test::cook-3084' do
4
+ include MiniTest ::Chef ::Assertions
5
+ include MiniTest ::Chef ::Context
6
+ include MiniTest ::Chef ::Resources
7
+
8
+ it "created a virtualenv in cook-3084" do
9
+ result = assert_sh ( "cook-3084/bin/python -c 'import sys; from os.path import basename; print basename(sys.prefix)'" )
10
+ assert_match /cook-3084\n / , result
11
+ end
12
+
13
+ it "created a virtualenv in cook-3084-interpreter" do
14
+ result = assert_sh ( "cook-3084-interpreter/bin/python -c 'import sys; from os.path import basename; print basename(sys.prefix)'" )
15
+ assert_match /cook-3084-interpreter\n / , result
16
+ end
17
+ end
Original file line number Diff line number Diff line change
1
+ #
2
+ # Author:: Alex Kiernan (<[email protected] >)
3
+ # Cookbook Name:: python
4
+ # Recipe:: cook-3084
5
+ #
6
+ # Copyright 2013, Alex Kiernan
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+
21
+ include_recipe "python"
22
+
23
+ python_virtualenv "cook-3084" do
24
+ end
25
+
26
+ python_virtualenv "cook-3084-interpreter" do
27
+ # on EL5 the default python we install is called python26
28
+ if !node [ 'python' ] [ 'install_method' ] . eql? ( "source" ) &&
29
+ platform_family? ( 'rhel' ) &&
30
+ node [ 'platform_version' ] . split ( '.' ) . first . to_i < 6
31
+ interpreter '/usr/bin/python26'
32
+ else
33
+ interpreter 'python'
34
+ end
35
+ end
Original file line number Diff line number Diff line change 19
19
#
20
20
21
21
python_virtualenv "/tmp/virtualenv" do
22
- interpreter "python"
23
22
owner "root"
24
23
group "root"
25
24
action :create
26
25
end
27
26
28
27
python_virtualenv "isolated python environment" do
29
28
path "/tmp/tobedestroyed"
30
- interpreter "python"
31
29
action :create
32
30
end
33
31
You can’t perform that action at this time.
0 commit comments