Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Installs and manages python, python-pip, python-dev, python-virtualenv and Gunic

**manage_gunicorn** - Allow Installation / Removal of Gunicorn. Default: true

**use_epel** - Boolean to determine if the epel class is used. Default: true
**use_epel** - Boolean to determine if the epel class is used. Default: true on RHEL like systems, false otherwise

```puppet
class { 'python' :
Expand Down
11 changes: 10 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@
'Debian' => ['3', '3.3', '2.7'],
'Suse' => [],
}
$use_epel = true

if $::osfamily == 'RedHat' {
if $::operatingsystem != 'Fedora' {
$use_epel = true
} else {
$use_epel = false
}
} else {
$use_epel = false
}

$gunicorn_package_name = $::osfamily ? {
'RedHat' => 'python-gunicorn',
Expand Down
41 changes: 41 additions & 0 deletions spec/classes/python_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,37 @@
it { is_expected.to contain_package("python-dev").with_ensure('absent') }
end
end

describe "EPEL does not exist for Debian" do
context "default/empty" do
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to set the facts with values for osfamily and operatingsystem. Will need three different tests to correspond with the code in params.

describe 'epel class' do
  context 'when osfamily is RedHat and operatingsystem is Fedora' do
    ...
  end
  context 'when osfamily is RedHat and operatingsystem is Fedora' do
    ...
  end
  context 'when osfamily is RedHat and operatingsystem is not Fedora' do
    ...
  end
  context 'when osfamily is not RedHat' do
    ...
  end
end

to set the facts, it would look like this

context 'whatever' do
  let(:facts) do
    {
      :osfamily        => 'RedHat',
      :operatingsystem => 'Fedora',
    }
end

it { should_not contain_class('epel') }
end
end

end

context "on a Fedora 22 OS" do
let :facts do
{
:id => 'root',
:kernel => 'Linux',
:osfamily => 'RedHat',
:operatingsystem => 'Fedora',
:operatingsystemrelease => '22',
:concat_basedir => '/dne',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end

describe "EPEL does not exist for Fedora" do
context "default/empty" do
it { should_not contain_class('epel') }
end
end

end


context "on a Redhat 5 OS" do
let :facts do
{
Expand All @@ -112,6 +141,12 @@
# Basic python packages (from pip)
it { is_expected.to contain_package("virtualenv")}

describe "EPEL may be needed on EL" do
context "default/empty" do
it { should contain_class('epel') }
end
end

describe "with python::dev" do
context "true" do
let (:params) {{ :dev => 'present' }}
Expand Down Expand Up @@ -271,5 +306,11 @@
it { is_expected.to contain_package("python-dev").with_ensure('absent') }
end
end

describe "EPEL does not exist on Suse" do
context "default/empty" do
it { should_not contain_class('epel') }
end
end
end
end