puppet-pip 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,190 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
|
4
|
+
|
5
|
+
provider_class = Puppet::Type.type(:package).provider(:pip)
|
6
|
+
|
7
|
+
describe provider_class do
|
8
|
+
|
9
|
+
before do
|
10
|
+
@resource = stub("resource")
|
11
|
+
@provider = provider_class.new
|
12
|
+
@provider.instance_variable_set(:@resource, @resource)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "parse" do
|
16
|
+
|
17
|
+
it "should return a hash on valid input" do
|
18
|
+
provider_class.parse("Django==1.2.5").should == {
|
19
|
+
:ensure => "1.2.5",
|
20
|
+
:name => "Django",
|
21
|
+
:provider => :pip,
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should return nil on invalid input" do
|
26
|
+
provider_class.parse("foo").should == nil
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "instances" do
|
32
|
+
|
33
|
+
it "should return an array when pip is present" do
|
34
|
+
provider_class.expects(:command).with(:pip).returns("/fake/bin/pip")
|
35
|
+
p = stub("process")
|
36
|
+
p.expects(:collect).yields("Django==1.2.5")
|
37
|
+
provider_class.expects(:execpipe).with("/fake/bin/pip freeze").yields(p)
|
38
|
+
provider_class.instances
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should return an empty array when pip is missing" do
|
42
|
+
provider_class.expects(:command).with(:pip).raises(
|
43
|
+
Puppet::DevError.new("Pretend pip isn't installed."))
|
44
|
+
provider_class.instances.should == []
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "query" do
|
50
|
+
|
51
|
+
before do
|
52
|
+
@resource.stubs(:[]).with(:name).returns("Django")
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should return a hash when pip and the package are present" do
|
56
|
+
@provider.expects(:command).with(:pip).returns("/fake/bin/pip")
|
57
|
+
p = stub("process")
|
58
|
+
p.expects(:each).yields("Django==1.2.5")
|
59
|
+
@provider.expects(:execpipe).with("/fake/bin/pip freeze").yields(p)
|
60
|
+
@provider.query.should == {
|
61
|
+
:ensure => "1.2.5",
|
62
|
+
:name => "Django",
|
63
|
+
:provider => :pip,
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should return nil when pip is missing" do
|
68
|
+
@provider.expects(:command).with(:pip).raises(
|
69
|
+
Puppet::DevError.new("Pretend pip isn't installed."))
|
70
|
+
@provider.query.should == nil
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should return nil when the package is missing" do
|
74
|
+
@provider.expects(:command).with(:pip).returns("/fake/bin/pip")
|
75
|
+
p = stub("process")
|
76
|
+
p.expects(:each).yields("sdsfdssdhdfyjymdgfcjdfjxdrssf==0.0.0")
|
77
|
+
@provider.expects(:execpipe).with("/fake/bin/pip freeze").yields(p)
|
78
|
+
@provider.query.should == nil
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "latest" do
|
84
|
+
|
85
|
+
it "should find a version number for Django" do
|
86
|
+
@resource.stubs(:[]).with(:name).returns "Django"
|
87
|
+
@provider.latest.should_not == nil
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should not find a version number for sdsfdssdhdfyjymdgfcjdfjxdrssf" do
|
91
|
+
@resource.stubs(:[]).with(:name).returns "sdsfdssdhdfyjymdgfcjdfjxdrssf"
|
92
|
+
@provider.latest.should == nil
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
describe "install" do
|
98
|
+
|
99
|
+
before do
|
100
|
+
@resource.stubs(:[]).with(:name).returns("sdsfdssdhdfyjymdgfcjdfjxdrssf")
|
101
|
+
@url = "git+https://example.com/sdsfdssdhdfyjymdgfcjdfjxdrssf.git"
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should install" do
|
105
|
+
@resource.stubs(:[]).with(:ensure).returns(:installed)
|
106
|
+
@resource.stubs(:[]).with(:source).returns(nil)
|
107
|
+
@provider.expects(:lazy_pip).with do |*args|
|
108
|
+
"install" == args[0] && "sdsfdssdhdfyjymdgfcjdfjxdrssf" == args[-1]
|
109
|
+
end.returns nil
|
110
|
+
@provider.install
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should install from SCM" do
|
114
|
+
@resource.stubs(:[]).with(:ensure).returns(:installed)
|
115
|
+
@resource.stubs(:[]).with(:source).returns(@url)
|
116
|
+
@provider.expects(:lazy_pip).with do |*args|
|
117
|
+
"#{@url}#egg=sdsfdssdhdfyjymdgfcjdfjxdrssf" == args[-1]
|
118
|
+
end.returns nil
|
119
|
+
@provider.install
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should install a particular revision" do
|
123
|
+
@resource.stubs(:[]).with(:ensure).returns("0123456")
|
124
|
+
@resource.stubs(:[]).with(:source).returns(@url)
|
125
|
+
@provider.expects(:lazy_pip).with do |*args|
|
126
|
+
"#{@url}@0123456#egg=sdsfdssdhdfyjymdgfcjdfjxdrssf" == args[-1]
|
127
|
+
end.returns nil
|
128
|
+
@provider.install
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should install a particular version" do
|
132
|
+
@resource.stubs(:[]).with(:ensure).returns("0.0.0")
|
133
|
+
@resource.stubs(:[]).with(:source).returns(nil)
|
134
|
+
@provider.expects(:lazy_pip).with do |*args|
|
135
|
+
"sdsfdssdhdfyjymdgfcjdfjxdrssf==0.0.0" == args[-1]
|
136
|
+
end.returns nil
|
137
|
+
@provider.install
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should upgrade" do
|
141
|
+
@resource.stubs(:[]).with(:ensure).returns(:latest)
|
142
|
+
@resource.stubs(:[]).with(:source).returns(nil)
|
143
|
+
@provider.expects(:lazy_pip).with do |*args|
|
144
|
+
"--upgrade" == args[-2] && "sdsfdssdhdfyjymdgfcjdfjxdrssf" == args[-1]
|
145
|
+
end.returns nil
|
146
|
+
@provider.install
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
|
151
|
+
describe "uninstall" do
|
152
|
+
|
153
|
+
it "should uninstall" do
|
154
|
+
@resource.stubs(:[]).with(:name).returns("sdsfdssdhdfyjymdgfcjdfjxdrssf")
|
155
|
+
@provider.expects(:lazy_pip).returns(nil)
|
156
|
+
@provider.uninstall
|
157
|
+
end
|
158
|
+
|
159
|
+
end
|
160
|
+
|
161
|
+
describe "update" do
|
162
|
+
|
163
|
+
it "should just call install" do
|
164
|
+
@provider.expects(:install).returns(nil)
|
165
|
+
@provider.update
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
|
170
|
+
describe "lazy_pip" do
|
171
|
+
|
172
|
+
it "should succeed if pip is present" do
|
173
|
+
@provider.stubs(:pip).returns(nil)
|
174
|
+
@provider.method(:lazy_pip).call "freeze"
|
175
|
+
end
|
176
|
+
|
177
|
+
it "should retry if pip has not yet been found" do
|
178
|
+
@provider.stubs(:pip).raises(NoMethodError).returns("/fake/bin/pip")
|
179
|
+
@provider.method(:lazy_pip).call "freeze"
|
180
|
+
end
|
181
|
+
|
182
|
+
it "should fail if pip is missing" do
|
183
|
+
@provider.stubs(:pip).twice.raises(NoMethodError)
|
184
|
+
expect { @provider.method(:lazy_pip).call("freeze") }.to \
|
185
|
+
raise_error(NoMethodError)
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-pip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Richard Crowley
|
@@ -42,6 +42,7 @@ extra_rdoc_files: []
|
|
42
42
|
|
43
43
|
files:
|
44
44
|
- lib/puppet/provider/package/pip.rb
|
45
|
+
- spec/unit/provider/package/pip_spec.rb
|
45
46
|
has_rdoc: true
|
46
47
|
homepage: http://github.com/rcrowley/puppet-pip
|
47
48
|
licenses: []
|