Skip to content

Commit 451d089

Browse files
committed
WIP venv testing
1 parent 4aeedb4 commit 451d089

File tree

4 files changed

+44
-12
lines changed

4 files changed

+44
-12
lines changed

manifests/install/venv.pp

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
class python::install::venv {
33
include python
44

5-
##
6-
## CentOS has no extra package for venv
7-
##
8-
unless $facts['os']['name'] == 'CentOS' {
5+
# Main python package bundle venv on some operating systems
6+
unless $facts['os']['name'] in ['Archlinux', 'CentOS', 'FreeBSD'] {
97
package { 'python-venv':
108
ensure => $python::venv,
119
name => "${python::install::python}-venv",

manifests/pyvenv.pp

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
Python::Venv::PipVersion $pip_version = 'latest',
3737
) {
3838
include python
39+
include python::install::venv
3940

4041
if $ensure == 'present' {
4142
$python_version = $version ? {

spec/classes/install/venv_spec.rb

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
describe 'python::install::venv' do
6+
on_supported_os.each do |os, facts|
7+
context "on #{os}" do
8+
let :facts do
9+
facts
10+
end
11+
12+
context 'with default settings' do
13+
if %w[Archlinux CentOS FreeBSD].include?(facts[:os]['name'])
14+
it { is_expected.not_to contain_package('python-venv') }
15+
else
16+
it { is_expected.to contain_package('python-venv').with(ensure: 'absent') }
17+
end
18+
end
19+
20+
context 'when ensuring venv is setup' do
21+
let(:pre_condition) do
22+
<<~PP
23+
class { 'python':
24+
venv => present,
25+
}
26+
PP
27+
end
28+
29+
if %w[Archlinux CentOS FreeBSD].include?(facts[:os]['name'])
30+
it { is_expected.not_to contain_package('python-venv') }
31+
else
32+
it { is_expected.to contain_package('python-venv').with(ensure: 'present') }
33+
end
34+
end
35+
end
36+
end
37+
end

spec/classes/python_spec.rb

+4-8
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
it { is_expected.to contain_package('pip') }
2424
end
2525

26-
if %w[Archlinux CentOS].include?(facts[:os]['name'])
27-
it { is_expected.not_to contain_package('python-venv') }
26+
if %w[Archlinux].include?(facts[:os]['name'])
27+
it { is_expected.not_to contain_class('python::install::venv') }
2828
else
29-
it { is_expected.to contain_package('python-venv') }
29+
it { is_expected.to contain_class('python::install::venv') }
3030
end
3131
end
3232

@@ -44,23 +44,19 @@
4444
it { is_expected.not_to contain_package('python') }
4545
it { is_expected.not_to contain_package('python-dev') }
4646
it { is_expected.not_to contain_package('pip') }
47-
it { is_expected.not_to contain_package('python-venv') }
47+
it { is_expected.not_to contain_class('python::install::venv') }
4848
end
4949

5050
context 'with packages present' do
5151
let :params do
5252
{
5353
manage_pip_package: true,
54-
manage_venv_package: true,
5554
pip: 'present',
56-
venv: 'present'
5755
}
5856
end
5957

6058
it { is_expected.to compile.with_all_deps }
6159
it { is_expected.to contain_package('pip').with(ensure: 'present') }
62-
63-
it { is_expected.to contain_package('python-venv').with(ensure: 'present') } unless facts[:os]['name'] == 'CentOS'
6460
end
6561

6662
case facts[:os]['family']

0 commit comments

Comments
 (0)