summaryrefslogtreecommitdiff
path: root/spec/classes/python_spec.rb
diff options
context:
space:
mode:
authorkwadronaut <kwadronaut@leap.se>2014-07-29 19:08:36 +0200
committerkwadronaut <kwadronaut@leap.se>2014-07-29 19:08:36 +0200
commitba32e368e22078cac65d27531a1cf7d0962ec984 (patch)
treed28ae4bd79d5d4f61ecf3d8b8cd55c9e306b960d /spec/classes/python_spec.rb
parent78c4e8d748138833ba07b71bcfc1ea538c4a2dfb (diff)
parent1696203589b66cc374bd8f5f21e82d5b92eb391b (diff)
Update: Merge remote-tracking branch 'upstream/master'HEADmaster
Diffstat (limited to 'spec/classes/python_spec.rb')
-rw-r--r--spec/classes/python_spec.rb228
1 files changed, 228 insertions, 0 deletions
diff --git a/spec/classes/python_spec.rb b/spec/classes/python_spec.rb
new file mode 100644
index 0000000..9552ce4
--- /dev/null
+++ b/spec/classes/python_spec.rb
@@ -0,0 +1,228 @@
+require_relative '../../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("python-pip") }
+ # Basic python packages (from pip)
+ it { is_expected.to contain_package("python-virtualenv")}
+
+ describe "with python::dev" do
+ context "true" do
+ let (:params) {{ :dev => true }}
+ 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("python-virtualenv")}
+ it { is_expected.to contain_package("python-pip")}
+
+ describe "with python::virtualenv" do
+ context "true" do
+ let (:params) {{
+ :provider => '',
+ :virtualenv => true
+ }}
+ it { is_expected.to contain_package("python-virtualenv").with(
+ "ensure" => "present"
+ )}
+ end
+ end
+
+ describe "with python::virtualenv" do
+ context "default/empty" do
+ let (:params) {{
+ :provider => '',
+ :virtualenv => ''
+ }}
+ it { is_expected.to contain_package("python-virtualenv").with(
+ "ensure" => "absent"
+ )}
+ end
+ end
+
+
+ end
+ end
+
+ describe "with python::dev" do
+ context "true" do
+ let (:params) {{ :dev => true }}
+ it { is_expected.to contain_package("python-dev").with(
+ "ensure" => "present")
+ }
+ end
+ context "default/empty" do
+ let (:params) {{ :dev => '' }}
+ it { is_expected.to contain_package("python-dev").with(
+ "ensure" => "absent")
+ }
+ 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-devel") }
+ it { is_expected.to contain_package("python-pip") }
+ # Basic python packages (from pip)
+ it { is_expected.to contain_package("python-virtualenv")}
+
+ describe "with python::dev" do
+ context "true" do
+ let (:params) {{ :dev => true }}
+ it { is_expected.to contain_package("python-devel").with(
+ "ensure" => "present")
+ }
+ end
+ context "empty/default" do
+ it { is_expected.to contain_package("python-devel").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("python-virtualenv")}
+ it { is_expected.to contain_package("python-pip")}
+
+ describe "with python::virtualenv" do
+ context "true" do
+ let (:params) {{
+ :provider => '',
+ :virtualenv => true
+ }}
+ it { is_expected.to contain_package("python-virtualenv").with(
+ "ensure" => "present"
+ )}
+ end
+ end
+
+ describe "with python::virtualenv" do
+ context "default/empty" do
+ let (:params) {{
+ :provider => '',
+ :virtualenv => ''
+ }}
+ it { is_expected.to contain_package("python-virtualenv").with(
+ "ensure" => "absent"
+ )}
+ end
+ end
+
+
+ end
+ end
+
+ describe "with python::dev" do
+ context "true" do
+ let (:params) {{ :dev => true }}
+ it { is_expected.to contain_package("python-devel").with(
+ "ensure" => "present")
+ }
+ end
+ context "default/empty" do
+ let (:params) {{ :dev => '' }}
+ it { is_expected.to contain_package("python-devel").with(
+ "ensure" => "absent")
+ }
+ end
+ end
+ end
+ end
+end