From 6bd87535749c11d3a519677b9a6c88b4330e962b Mon Sep 17 00:00:00 2001 From: Daniel Lawrence Date: Sun, 27 Jul 2014 19:42:03 +1000 Subject: started adding spec tests --- spec/classes/python_spec.rb | 70 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 spec/classes/python_spec.rb (limited to 'spec') diff --git a/spec/classes/python_spec.rb b/spec/classes/python_spec.rb new file mode 100644 index 0000000..af94b70 --- /dev/null +++ b/spec/classes/python_spec.rb @@ -0,0 +1,70 @@ +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 manage_gunicorn" do + context "true" do + let (:params) {{ :manage_gunicorn => true }} + it { is_expected.to contain_package("gunicorn") } + end + end + describe "with manage_gunicorn" do + context "empty args" do + #let (:params) {{ :manage_gunicorn => '' }} + it { is_expected.to contain_package("gunicorn") } + end + end + + describe "without mange_gunicorn" do + context "false" do + let (:params) {{ :manage_gunicorn => false }} + it {is_expected.not_to contain_package("gunicorn")} + 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-devel") } + it { is_expected.to contain_package("python-pip") } + # Basic python packages (from pip) + it { is_expected.to contain_package("python-virtualenv")} + + end + +end -- cgit v1.2.3 From 3f9c7dd32c500906a17a4729dc5418e354f19786 Mon Sep 17 00:00:00 2001 From: Daniel Lawrence Date: Sun, 27 Jul 2014 20:44:36 +1000 Subject: increase spec coverage of puppet::install --- spec/classes/python_spec.rb | 170 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 164 insertions(+), 6 deletions(-) (limited to 'spec') diff --git a/spec/classes/python_spec.rb b/spec/classes/python_spec.rb index af94b70..9552ce4 100644 --- a/spec/classes/python_spec.rb +++ b/spec/classes/python_spec.rb @@ -22,27 +22,96 @@ describe 'python', :type => :class do 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 - end - describe "with manage_gunicorn" do context "empty args" do #let (:params) {{ :manage_gunicorn => '' }} it { is_expected.to contain_package("gunicorn") } end - end - - describe "without mange_gunicorn" do 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 @@ -64,7 +133,96 @@ describe 'python', :type => :class do 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 - 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 -- cgit v1.2.3 From 58c24bfd724fd1146b40e0ec248b230d7b6389d8 Mon Sep 17 00:00:00 2001 From: Daniel Lawrence Date: Sun, 27 Jul 2014 21:09:08 +1000 Subject: started adding checks for python::requirements --- spec/defines/requirements_spec.rb | 53 +++++++++++++++++++++++++++++++++++++ spec/defines/requirements_spec.rb~ | 54 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 spec/defines/requirements_spec.rb create mode 100644 spec/defines/requirements_spec.rb~ (limited to 'spec') diff --git a/spec/defines/requirements_spec.rb b/spec/defines/requirements_spec.rb new file mode 100644 index 0000000..f8144f3 --- /dev/null +++ b/spec/defines/requirements_spec.rb @@ -0,0 +1,53 @@ +require_relative '../../spec_helper' + +describe 'python::requirements', :type => :define do + let (:title) { '/requirements.txt' } + 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 + + describe "requirements as" do + context "/requirements.txt" do + let (:params) {{ :requirements => "/requirements.txt" }} + it { is_expected.to contain_file("/requirements.txt").with( + "mode" => "0644" + + )} + end + + describe "with owner" do + context "bob:bob" do + let (:params) {{ + :owner => 'bob', + :group => 'bob' + }} + it do + expect { + should compile + }.to raise_error(Puppet::Error, /root user must be used when virtualenv is system/) + end + + end + end + + describe "with owner" do + context "default" do + it { is_expected.to contain_file("/requirements.txt").with( + "owner" => "root", + "group" => "root" + )} + end + end + end + end +end diff --git a/spec/defines/requirements_spec.rb~ b/spec/defines/requirements_spec.rb~ new file mode 100644 index 0000000..62a8254 --- /dev/null +++ b/spec/defines/requirements_spec.rb~ @@ -0,0 +1,54 @@ +require_relative '../../spec_helper' + +describe 'python::requirements', :type => :define 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 + + describe "requirements as" do + context "/requirements.txt" do + let (:params) {{ :requirements => "/requirements.txt" }} + it { is_expected.to contain_file("/requirements.txt").with( + "mode" => "0644" + + )} + end + + describe "with owner" do + context "bob:bob" do + let (:params) {{ + :owner => 'bob', + :group => 'bob' + }} + it { is_expected.to contain_file("/requirements.txt").with( + "owner" => "bob", + "group" => "bob" + )} + end + end + + describe "with owner" do + context "default" do + let (:params) {{ + :owner => '', + :group => '' + }} + it { is_expected.to contain_file("/requirements.txt").with( + "owner" => "root", + "group" => "root" + )} + end + end + end + end +end -- cgit v1.2.3 From 62be88b026e19e1750deaf5cf81b3f9519ff651a Mon Sep 17 00:00:00 2001 From: Daniel Lawrence Date: Sun, 27 Jul 2014 21:12:10 +1000 Subject: removed tmp files --- spec/defines/requirements_spec.rb~ | 54 -------------------------------------- 1 file changed, 54 deletions(-) delete mode 100644 spec/defines/requirements_spec.rb~ (limited to 'spec') diff --git a/spec/defines/requirements_spec.rb~ b/spec/defines/requirements_spec.rb~ deleted file mode 100644 index 62a8254..0000000 --- a/spec/defines/requirements_spec.rb~ +++ /dev/null @@ -1,54 +0,0 @@ -require_relative '../../spec_helper' - -describe 'python::requirements', :type => :define 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 - - describe "requirements as" do - context "/requirements.txt" do - let (:params) {{ :requirements => "/requirements.txt" }} - it { is_expected.to contain_file("/requirements.txt").with( - "mode" => "0644" - - )} - end - - describe "with owner" do - context "bob:bob" do - let (:params) {{ - :owner => 'bob', - :group => 'bob' - }} - it { is_expected.to contain_file("/requirements.txt").with( - "owner" => "bob", - "group" => "bob" - )} - end - end - - describe "with owner" do - context "default" do - let (:params) {{ - :owner => '', - :group => '' - }} - it { is_expected.to contain_file("/requirements.txt").with( - "owner" => "root", - "group" => "root" - )} - end - end - end - end -end -- cgit v1.2.3