|
| 1 | +# frozen_string_literal: true |
| 2 | + |
1 | 3 | require 'spec_helper' |
2 | 4 | describe 'python' do |
3 | 5 | on_supported_os.each do |os, facts| |
4 | 6 | next if os == 'gentoo-3-x86_64' |
| 7 | + |
5 | 8 | context "on #{os}" do |
6 | 9 | let :facts do |
7 | 10 | facts |
|
51 | 54 | end |
52 | 55 | end |
53 | 56 |
|
| 57 | + # rubocop:disable RSpec/RepeatedExampleGroupDescription |
54 | 58 | describe 'with python::dev' do |
55 | 59 | context 'true' do |
56 | 60 | let(:params) { { dev: 'present' } } |
57 | 61 |
|
58 | 62 | it { is_expected.to compile.with_all_deps } |
59 | 63 | it { is_expected.to contain_package('python-dev').with_ensure('present') } |
60 | 64 | end |
| 65 | + |
61 | 66 | context 'empty/default' do |
62 | 67 | it { is_expected.to compile.with_all_deps } |
63 | 68 | it { is_expected.to contain_package('python-dev').with_ensure('absent') } |
|
117 | 122 |
|
118 | 123 | it { is_expected.to contain_python__pyvenv('/opt/env1').with_ensure('present') } |
119 | 124 | it { is_expected.to contain_python__pyvenv('/opt/env2').with_ensure('present') } |
| 125 | + |
120 | 126 | it { |
121 | | - is_expected.to contain_exec('python_virtualenv_/opt/env1'). |
| 127 | + expect(subject).to contain_exec('python_virtualenv_/opt/env1'). |
122 | 128 | with( |
123 | 129 | command: 'python3.8 -m venv --clear /opt/env1 && /opt/env1/bin/pip --log /opt/env1/pip.log install --upgrade pip && /opt/env1/bin/pip --log /opt/env1/pip.log install --upgrade setuptools', |
124 | 130 | user: 'root', |
|
132 | 138 | cwd: '/tmp', |
133 | 139 | environment: [], |
134 | 140 | timeout: 600, |
135 | | - unless: %r{^grep '\^\[\\t \]\*VIRTUAL_ENV=\[\\\\'\\\"\]\*/opt/env1\[\\\"\\\\'\]\[\\t \]\*\$' /opt/env1/bin/activate$} |
| 141 | + unless: %r{^grep '\^\[\\t \]\*VIRTUAL_ENV=\[\\\\'\\"\]\*/opt/env1\[\\"\\\\'\]\[\\t \]\*\$' /opt/env1/bin/activate$} |
136 | 142 | ). |
137 | 143 | that_requires('File[/opt/env1]') |
138 | 144 | } |
| 145 | + |
139 | 146 | it { |
140 | | - is_expected.to contain_exec('python_virtualenv_/opt/env2'). |
| 147 | + expect(subject).to contain_exec('python_virtualenv_/opt/env2'). |
141 | 148 | with( |
142 | 149 | command: 'python3.8 -m venv --clear /opt/env2 && /opt/env2/bin/pip --log /opt/env2/pip.log install --upgrade \'pip <= 20.3.4\' && /opt/env2/bin/pip --log /opt/env2/pip.log install --upgrade setuptools', |
143 | 150 | user: 'root', |
|
151 | 158 | cwd: '/tmp', |
152 | 159 | environment: [], |
153 | 160 | timeout: 600, |
154 | | - unless: %r{^grep '\^\[\\t \]\*VIRTUAL_ENV=\[\\\\'\\\"\]\*/opt/env2\[\\\"\\\\'\]\[\\t \]\*\$' /opt/env2/bin/activate$} |
| 161 | + unless: %r{^grep '\^\[\\t \]\*VIRTUAL_ENV=\[\\\\'\\"\]\*/opt/env2\[\\"\\\\'\]\[\\t \]\*\$' /opt/env2/bin/activate$} |
155 | 162 | ). |
156 | 163 | that_requires('File[/opt/env2]') |
157 | 164 | } |
| 165 | + |
158 | 166 | it { is_expected.to contain_file('/opt/env1') } |
159 | 167 | it { is_expected.to contain_file('/opt/env2') } |
160 | 168 | end |
|
166 | 174 |
|
167 | 175 | it { is_expected.to contain_package('gunicorn') } |
168 | 176 | end |
| 177 | + |
169 | 178 | context 'empty args' do |
170 | 179 | # let(:params) {{ :manage_gunicorn => '' }} |
171 | 180 | it { is_expected.to contain_package('gunicorn') } |
172 | 181 | end |
| 182 | + |
173 | 183 | context 'false' do |
174 | 184 | let(:params) { { manage_gunicorn: false } } |
175 | 185 |
|
|
198 | 208 |
|
199 | 209 | it { is_expected.to contain_package('python-dev').with_ensure('present') } |
200 | 210 | end |
| 211 | + |
201 | 212 | context 'default/empty' do |
202 | 213 | it { is_expected.to contain_package('python-dev').with_ensure('absent') } |
203 | 214 | end |
|
246 | 257 |
|
247 | 258 | it { is_expected.to contain_package('gunicorn').with_name('python-gunicorn') } |
248 | 259 | end |
| 260 | + |
249 | 261 | context 'empty args' do |
250 | 262 | # let(:params) {{ :manage_gunicorn => '' }} |
251 | 263 | it { is_expected.to contain_package('gunicorn').with_name('python-gunicorn') } |
252 | 264 | end |
| 265 | + |
253 | 266 | context 'false' do |
254 | 267 | let(:params) { { manage_gunicorn: false } } |
255 | 268 |
|
|
265 | 278 |
|
266 | 279 | it { is_expected.to compile.with_all_deps } |
267 | 280 | end |
| 281 | + |
268 | 282 | context '3.6 SCL python package' do |
269 | 283 | let(:params) { { version: 'rh-python36-python' } } |
270 | 284 |
|
271 | 285 | it { is_expected.to compile.with_all_deps } |
272 | 286 | end |
273 | 287 | end |
| 288 | + |
274 | 289 | describe 'with manage_scl' do |
275 | 290 | context 'true' do |
276 | 291 | let(:params) { { provider: 'scl', manage_scl: true } } |
277 | 292 |
|
278 | 293 | it { is_expected.to contain_package('centos-release-scl') } |
279 | 294 | it { is_expected.to contain_package('scl-utils') } |
280 | 295 | end |
| 296 | + |
281 | 297 | context 'false' do |
282 | 298 | let(:params) { { provider: 'scl', manage_scl: false } } |
283 | 299 |
|
|
310 | 326 |
|
311 | 327 | it { is_expected.to contain_package('gunicorn').with_name('python3-gunicorn') } |
312 | 328 | end |
| 329 | + |
313 | 330 | context 'empty args' do |
314 | 331 | # let(:params) {{ :manage_gunicorn => '' }} |
315 | 332 | it { is_expected.to contain_package('gunicorn').with_name('python3-gunicorn') } |
316 | 333 | end |
| 334 | + |
317 | 335 | context 'false' do |
318 | 336 | let(:params) { { manage_gunicorn: false } } |
319 | 337 |
|
|
329 | 347 |
|
330 | 348 | it { is_expected.to compile.with_all_deps } |
331 | 349 | end |
| 350 | + |
332 | 351 | context '3.6 SCL python package' do |
333 | 352 | let(:params) { { version: 'rh-python36-python' } } |
334 | 353 |
|
335 | 354 | it { is_expected.to compile.with_all_deps } |
336 | 355 | end |
337 | 356 | end |
| 357 | + |
338 | 358 | describe 'with manage_scl' do |
339 | 359 | context 'true' do |
340 | 360 | let(:params) { { provider: 'scl', manage_scl: true } } |
341 | 361 |
|
342 | 362 | it { is_expected.to contain_package('centos-release-scl') } |
343 | 363 | it { is_expected.to contain_package('scl-utils') } |
344 | 364 | end |
| 365 | + |
345 | 366 | context 'false' do |
346 | 367 | let(:params) { { provider: 'scl', manage_scl: false } } |
347 | 368 |
|
|
371 | 392 |
|
372 | 393 | it { is_expected.to contain_package('python-dev').with_ensure('present') } |
373 | 394 | end |
| 395 | + |
374 | 396 | context 'empty/default' do |
375 | 397 | it { is_expected.to contain_package('python-dev').with_ensure('absent') } |
376 | 398 | end |
|
382 | 404 |
|
383 | 405 | it { is_expected.to contain_package('gunicorn') } |
384 | 406 | end |
| 407 | + |
385 | 408 | context 'empty args' do |
386 | 409 | # let(:params) {{ :manage_gunicorn => '' }} |
387 | 410 | it { is_expected.to contain_package('gunicorn') } |
388 | 411 | end |
| 412 | + |
389 | 413 | context 'false' do |
390 | 414 | let(:params) { { manage_gunicorn: false } } |
391 | 415 |
|
|
398 | 422 | let(:params) { { provider: 'pip' } } |
399 | 423 |
|
400 | 424 | it { |
401 | | - is_expected.to contain_package('pip').with( |
| 425 | + expect(subject).to contain_package('pip').with( |
402 | 426 | 'provider' => 'pip' |
403 | 427 | ) |
404 | 428 | } |
|
418 | 442 |
|
419 | 443 | it { is_expected.to contain_package('python-dev').with_ensure('present') } |
420 | 444 | end |
| 445 | + |
421 | 446 | context 'default/empty' do |
422 | 447 | it { is_expected.to contain_package('python-dev').with_ensure('absent') } |
423 | 448 | end |
|
445 | 470 |
|
446 | 471 | it { is_expected.to contain_package('gunicorn') } |
447 | 472 | end |
| 473 | + |
448 | 474 | context 'empty args' do |
449 | 475 | # let(:params) {{ :manage_gunicorn => '' }} |
450 | 476 | it { is_expected.to contain_package('gunicorn') } |
451 | 477 | end |
| 478 | + |
452 | 479 | context 'false' do |
453 | 480 | let(:params) { { manage_gunicorn: false } } |
454 | 481 |
|
|
468 | 495 | end |
469 | 496 | end |
470 | 497 | end |
| 498 | +# rubocop:enable RSpec/RepeatedExampleGroupDescription |
0 commit comments