forked from voxpupuli/puppet-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor rspec tests to use rspec-puppet-facts
- Loading branch information
1 parent
a10f9c4
commit 4159db4
Showing
3 changed files
with
88 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,276 +1,99 @@ | ||
require 'spec_helper' | ||
|
||
describe 'python', :type => :class do | ||
context "on Debian OS" do | ||
let :facts do | ||
{ | ||
:id => 'root', | ||
:kernel => 'Linux', | ||
:lsbdistcodename => 'squeeze', | ||
:osfamily => 'Debian', | ||
:operatingsystem => 'Debian', | ||
:operatingsystemrelease => '6', | ||
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', | ||
:concat_basedir => '/dne', | ||
} | ||
end | ||
|
||
it { is_expected.to contain_class("python::install") } | ||
# Base debian packages. | ||
it { is_expected.to contain_package("python") } | ||
it { is_expected.to contain_package("python-dev") } | ||
it { is_expected.to contain_package("pip") } | ||
# Basic python packages (from pip) | ||
it { is_expected.to contain_package("virtualenv")} | ||
|
||
describe "with python::dev" do | ||
context "true" do | ||
let (:params) {{ :dev => 'present' }} | ||
it { is_expected.to contain_package("python-dev").with_ensure('present') } | ||
end | ||
context "empty/default" do | ||
it { is_expected.to contain_package("python-dev").with_ensure('absent') } | ||
end | ||
end | ||
|
||
describe "with manage_gunicorn" do | ||
context "true" do | ||
let (:params) {{ :manage_gunicorn => true }} | ||
it { is_expected.to contain_package("gunicorn") } | ||
end | ||
context "empty args" do | ||
#let (:params) {{ :manage_gunicorn => '' }} | ||
it { is_expected.to contain_package("gunicorn") } | ||
end | ||
context "false" do | ||
let (:params) {{ :manage_gunicorn => false }} | ||
it {is_expected.not_to contain_package("gunicorn")} | ||
end | ||
end | ||
|
||
describe "with python::provider" do | ||
context "pip" do | ||
let (:params) {{ :provider => 'pip' }} | ||
it { is_expected.to contain_package("virtualenv").with( | ||
'provider' => 'pip' | ||
)} | ||
it { is_expected.to contain_package("pip").with( | ||
'provider' => 'pip' | ||
)} | ||
end | ||
|
||
# python::provider | ||
context "default" do | ||
let (:params) {{ :provider => '' }} | ||
it { is_expected.to contain_package("virtualenv")} | ||
it { is_expected.to contain_package("pip")} | ||
|
||
describe "with python::virtualenv" do | ||
context "true" do | ||
let (:params) {{ :provider => '', :virtualenv => true }} | ||
it { is_expected.to contain_package("virtualenv").with_ensure('present') } | ||
end | ||
on_supported_os.each do |os, facts| | ||
context "on #{os}" do | ||
let :facts do | ||
facts | ||
end | ||
|
||
it { is_expected.to contain_class("python::install") } | ||
# Base debian packages. | ||
it { is_expected.to contain_package("python") } | ||
case facts[:osfamily] | ||
when 'Debian' | ||
it { is_expected.to contain_package("python-dev").with_alias("python-dev") } | ||
when 'RedHat', 'Suse' | ||
it { is_expected.to contain_package("python-dev").with_name("python-devel") } | ||
it { is_expected.to contain_package("python-dev").with_alias("python-devel") } | ||
end | ||
|
||
it { is_expected.to contain_package("pip") } | ||
# Basic python packages (from pip) | ||
it { is_expected.to contain_package("virtualenv")} | ||
|
||
describe "with python::dev" do | ||
context "true" do | ||
let (:params) {{ :dev => 'present' }} | ||
it { is_expected.to contain_package("python-dev").with_ensure('present') } | ||
end | ||
|
||
describe "without python::virtualenv" do | ||
context "default/empty" do | ||
let (:params) {{ :provider => '' }} | ||
it { is_expected.to contain_package("virtualenv").with_ensure('absent') } | ||
end | ||
context "empty/default" do | ||
it { is_expected.to contain_package("python-dev").with_ensure('absent') } | ||
end | ||
end | ||
end | ||
|
||
describe "with python::dev" do | ||
context "true" do | ||
let (:params) {{ :dev => 'present' }} | ||
it { is_expected.to contain_package("python-dev").with_ensure('present') } | ||
end | ||
context "default/empty" do | ||
it { is_expected.to contain_package("python-dev").with_ensure('absent') } | ||
end | ||
end | ||
end | ||
|
||
context "on a Redhat 5 OS" do | ||
let :facts do | ||
{ | ||
:id => 'root', | ||
:kernel => 'Linux', | ||
:osfamily => 'RedHat', | ||
:operatingsystem => 'RedHat', | ||
:operatingsystemrelease => '5', | ||
:concat_basedir => '/dne', | ||
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', | ||
} | ||
end | ||
it { is_expected.to contain_class("python::install") } | ||
# Base debian packages. | ||
it { is_expected.to contain_package("python") } | ||
it { is_expected.to contain_package("python-dev").with_name("python-devel") } | ||
it { is_expected.to contain_package("python-dev").with_alias("python-devel") } | ||
it { is_expected.to contain_package("pip") } | ||
# Basic python packages (from pip) | ||
it { is_expected.to contain_package("virtualenv")} | ||
|
||
describe "with python::dev" do | ||
context "true" do | ||
let (:params) {{ :dev => 'present' }} | ||
it { is_expected.to contain_package("python-dev").with_ensure('present') } | ||
end | ||
context "empty/default" do | ||
it { is_expected.to contain_package("python-dev").with_ensure('absent') } | ||
end | ||
end | ||
|
||
describe "with manage_gunicorn" do | ||
context "true" do | ||
let (:params) {{ :manage_gunicorn => true }} | ||
it { is_expected.to contain_package("gunicorn") } | ||
end | ||
context "empty args" do | ||
#let (:params) {{ :manage_gunicorn => '' }} | ||
it { is_expected.to contain_package("gunicorn") } | ||
end | ||
context "false" do | ||
let (:params) {{ :manage_gunicorn => false }} | ||
it {is_expected.not_to contain_package("gunicorn")} | ||
end | ||
end | ||
|
||
describe "with python::provider" do | ||
context "pip" do | ||
let (:params) {{ :provider => 'pip' }} | ||
|
||
it { is_expected.to contain_package("virtualenv").with( | ||
'provider' => 'pip' | ||
)} | ||
it { is_expected.to contain_package("pip").with( | ||
'provider' => 'pip' | ||
)} | ||
end | ||
|
||
# python::provider | ||
context "default" do | ||
let (:params) {{ :provider => '' }} | ||
it { is_expected.to contain_package("virtualenv")} | ||
it { is_expected.to contain_package("pip")} | ||
|
||
describe "with python::virtualenv" do | ||
context "true" do | ||
let (:params) {{ :provider => '', :virtualenv => 'present' }} | ||
it { is_expected.to contain_package("virtualenv").with_ensure('present') } | ||
end | ||
describe "with manage_gunicorn" do | ||
context "true" do | ||
let (:params) {{ :manage_gunicorn => true }} | ||
it { is_expected.to contain_package("gunicorn") } | ||
end | ||
|
||
describe "with python::virtualenv" do | ||
context "default/empty" do | ||
let (:params) {{ :provider => '' }} | ||
it { is_expected.to contain_package("virtualenv").with_ensure('absent') } | ||
end | ||
context "empty args" do | ||
#let (:params) {{ :manage_gunicorn => '' }} | ||
it { is_expected.to contain_package("gunicorn") } | ||
end | ||
context "false" do | ||
let (:params) {{ :manage_gunicorn => false }} | ||
it {is_expected.not_to contain_package("gunicorn")} | ||
end | ||
end | ||
end | ||
|
||
describe "with python::dev" do | ||
context "true" do | ||
let (:params) {{ :dev => 'present' }} | ||
it { is_expected.to contain_package("python-dev").with_ensure('present') } | ||
end | ||
context "default/empty" do | ||
it { is_expected.to contain_package("python-dev").with_ensure('absent') } | ||
end | ||
end | ||
end | ||
|
||
context "on a SLES 11 SP3" do | ||
let :facts do | ||
{ | ||
:id => 'root', | ||
:kernel => 'Linux', | ||
:lsbdistcodename => nil, | ||
:osfamily => 'Suse', | ||
:operatingsystem => 'SLES', | ||
:operatingsystemrelease => '11.3', | ||
:concat_basedir => '/dne', | ||
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', | ||
} | ||
end | ||
it { is_expected.to contain_class("python::install") } | ||
# Base Suse packages. | ||
it { is_expected.to contain_package("python") } | ||
it { is_expected.to contain_package("python-dev").with_name("python-devel") } | ||
it { is_expected.to contain_package("pip") } | ||
# Basic python packages (from pip) | ||
it { is_expected.to contain_package("virtualenv")} | ||
|
||
describe "with python::dev" do | ||
context "true" do | ||
let (:params) {{ :dev => 'present' }} | ||
it { is_expected.to contain_package("python-dev").with_ensure('present') } | ||
end | ||
context "empty/default" do | ||
it { is_expected.to contain_package("python-dev").with_ensure('absent') } | ||
end | ||
end | ||
|
||
describe "with manage_gunicorn" do | ||
context "true" do | ||
let (:params) {{ :manage_gunicorn => true }} | ||
it { is_expected.to contain_package("gunicorn") } | ||
end | ||
context "empty args" do | ||
#let (:params) {{ :manage_gunicorn => '' }} | ||
it { is_expected.to contain_package("gunicorn") } | ||
end | ||
context "false" do | ||
let (:params) {{ :manage_gunicorn => false }} | ||
it {is_expected.not_to contain_package("gunicorn")} | ||
end | ||
end | ||
|
||
describe "with python::provider" do | ||
context "pip" do | ||
let (:params) {{ :provider => 'pip' }} | ||
|
||
it { is_expected.to contain_package("virtualenv").with( | ||
'provider' => 'pip' | ||
)} | ||
it { is_expected.to contain_package("pip").with( | ||
'provider' => 'pip' | ||
)} | ||
end | ||
|
||
# python::provider | ||
context "default" do | ||
let (:params) {{ :provider => '' }} | ||
it { is_expected.to contain_package("virtualenv")} | ||
it { is_expected.to contain_package("pip")} | ||
describe "with python::provider" do | ||
context "pip" do | ||
let (:params) {{ :provider => 'pip' }} | ||
it { is_expected.to contain_package("virtualenv").with( | ||
'provider' => 'pip' | ||
)} | ||
it { is_expected.to contain_package("pip").with( | ||
'provider' => 'pip' | ||
)} | ||
end | ||
|
||
describe "with python::virtualenv" do | ||
context "true" do | ||
let (:params) {{ :provider => '', :virtualenv => 'present' }} | ||
it { is_expected.to contain_package("virtualenv").with_ensure('present') } | ||
# python::provider | ||
context "default" do | ||
let (:params) {{ :provider => '' }} | ||
it { is_expected.to contain_package("virtualenv")} | ||
it { is_expected.to contain_package("pip")} | ||
|
||
describe "with python::virtualenv" do | ||
context "true" do | ||
case facts[:osfamily] | ||
when 'Debian' | ||
let (:params) {{ :provider => '', :virtualenv => true }} | ||
when 'RedHat', 'Suse' | ||
let (:params) {{ :provider => '', :virtualenv => 'present' }} | ||
end | ||
it { is_expected.to contain_package("virtualenv").with_ensure('present') } | ||
end | ||
end | ||
end | ||
|
||
describe "with python::virtualenv" do | ||
context "default/empty" do | ||
let (:params) {{ :provider => '' }} | ||
it { is_expected.to contain_package("virtualenv").with_ensure('absent') } | ||
case facts[:osfamily] | ||
when 'Debian' | ||
describe "without python::virtualenv" do | ||
context "default/empty" do | ||
let (:params) {{ :provider => '' }} | ||
it { is_expected.to contain_package("virtualenv").with_ensure('absent') } | ||
end | ||
end | ||
when 'RedHat', 'Suse' | ||
describe "with python::virtualenv" do | ||
context "default/empty" do | ||
let (:params) {{ :provider => '' }} | ||
it { is_expected.to contain_package("virtualenv").with_ensure('absent') } | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
describe "with python::dev" do | ||
context "true" do | ||
let (:params) {{ :dev => 'present' }} | ||
it { is_expected.to contain_package("python-dev").with_ensure('present') } | ||
end | ||
context "default/empty" do | ||
it { is_expected.to contain_package("python-dev").with_ensure('absent') } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
require 'puppetlabs_spec_helper/module_spec_helper' | ||
require 'rspec-puppet-facts' | ||
include RspecPuppetFacts | ||
add_custom_fact :id, 'root' | ||
add_custom_fact :kernel, 'Linux' | ||
add_custom_fact :concat_basedir, '/dne' | ||
add_custom_fact :path, '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' | ||
add_custom_fact :lsbdistcodename, 'squeeze', :confine => 'debian-6-x86_64' | ||
add_custom_fact :lsbdistcodename, 'nil', :confine => 'sles-11.3-x86_64' |