forked from voxpupuli/puppet-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpip_spec.rb
More file actions
111 lines (93 loc) · 2.89 KB
/
pip_spec.rb
File metadata and controls
111 lines (93 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# frozen_string_literal: true
require 'spec_helper_acceptance'
describe 'python::pip defined resource' do
context 'install package with custom name' do
it 'works with no errors' do
pp = <<-PUPPET
class { 'python':
dev => 'present',
}
python::pyvenv { '/opt/test-venv':
ensure => 'present',
systempkgs => false,
mode => '0755',
pip_version => '<= 20.3.4',
}
python::pip { 'agent package':
virtualenv => '/opt/test-venv',
pkgname => 'agent',
ensure => '0.1.2',
}
PUPPET
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end
end
# rubocop:disable RSpec/RepeatedExampleGroupDescription
# rubocop:disable RSpec/RepeatedExampleGroupBody
describe command('/opt/test-venv/bin/pip list') do
its(:exit_status) { is_expected.to eq 0 }
its(:stdout) { is_expected.to match %r{agent.* 0\.1\.2} }
end
context 'uninstall package with custom name' do
it 'works with no errors' do
pp = <<-PUPPET
class { 'python':
dev => 'present',
}
python::pyvenv { '/opt/test-venv':
ensure => 'present',
systempkgs => false,
mode => '0755',
pip_version => '<= 20.3.4',
}
python::pip { 'agent package install':
ensure => '0.1.2',
pkgname => 'agent',
virtualenv => '/opt/test-venv',
}
python::pip { 'agent package uninstall custom pkgname':
ensure => 'absent',
pkgname => 'agent',
virtualenv => '/opt/test-venv',
require => Python::Pip['agent package install'],
}
PUPPET
apply_manifest(pp, catch_failures: true)
end
end
describe command('/opt/test-venv/bin/pip list') do
its(:exit_status) { is_expected.to eq 0 }
its(:stdout) { is_expected.not_to match %r{agent.* 0\.1\.2} }
end
context 'install package via extra_index' do
it 'works with no errors' do
pp = <<-PUPPET
class { 'python':
dev => 'present',
}
python::pyvenv { '/opt/test-venv':
ensure => 'present',
systempkgs => false,
mode => '0755',
pip_version => '<= 20.3.4',
}
python::pip { 'agent package via extra_index':
virtualenv => '/opt/test-venv',
pkgname => 'agent',
index => 'invalid',
extra_index => 'https://pypi.org/simple',
ensure => '0.1.2',
}
PUPPET
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end
end
describe command('/opt/test-venv/bin/pip list') do
its(:exit_status) { is_expected.to eq 0 }
its(:stdout) { is_expected.to match %r{agent.* 0\.1\.2} }
end
# rubocop:enable RSpec/RepeatedExampleGroupBody
# rubocop:enable RSpec/RepeatedExampleGroupDescription
end