]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/apache/spec/classes/mod/wsgi_spec.rb
add Openstack modules to 3rdparty
[dsa-puppet.git] / 3rdparty / modules / apache / spec / classes / mod / wsgi_spec.rb
1 require 'spec_helper'
2
3 describe 'apache::mod::wsgi', :type => :class do
4   let :pre_condition do
5     'include apache'
6   end
7   context "on a Debian OS" do
8     let :facts do
9       {
10         :osfamily               => 'Debian',
11         :operatingsystemrelease => '6',
12         :concat_basedir         => '/dne',
13         :lsbdistcodename        => 'squeeze',
14         :operatingsystem        => 'Debian',
15         :id                     => 'root',
16         :kernel                 => 'Linux',
17         :path                   => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
18         :is_pe                  => false,
19       }
20     end
21     it { is_expected.to contain_class("apache::params") }
22     it { is_expected.to contain_class('apache::mod::wsgi').with(
23         'wsgi_socket_prefix' => nil
24       )
25     }
26     it { is_expected.to contain_package("libapache2-mod-wsgi") }
27   end
28   context "on a RedHat OS" do
29     let :facts do
30       {
31         :osfamily               => 'RedHat',
32         :operatingsystemrelease => '6',
33         :concat_basedir         => '/dne',
34         :operatingsystem        => 'RedHat',
35         :id                     => 'root',
36         :kernel                 => 'Linux',
37         :path                   => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
38         :is_pe                  => false,
39       }
40     end
41     it { is_expected.to contain_class("apache::params") }
42     it { is_expected.to contain_class('apache::mod::wsgi').with(
43         'wsgi_socket_prefix' => '/var/run/wsgi'
44       )
45     }
46     it { is_expected.to contain_package("mod_wsgi") }
47
48     describe "with custom WSGISocketPrefix" do
49       let :params do
50         { :wsgi_socket_prefix => 'run/wsgi' }
51       end
52       it {is_expected.to contain_file('wsgi.conf').with_content(/^  WSGISocketPrefix run\/wsgi$/)}
53     end
54     describe "with custom WSGIPythonHome" do
55       let :params do
56         { :wsgi_python_home => '/path/to/virtenv' }
57       end
58       it {is_expected.to contain_file('wsgi.conf').with_content(/^  WSGIPythonHome "\/path\/to\/virtenv"$/)}
59     end
60     describe "with custom package_name and mod_path" do
61       let :params do
62         {
63           :package_name => 'mod_wsgi_package',
64           :mod_path     => '/foo/bar/baz',
65         }
66       end
67       it { is_expected.to contain_apache__mod('wsgi').with({
68           'package' => 'mod_wsgi_package',
69           'path'    => '/foo/bar/baz',
70         })
71       }
72       it { is_expected.to contain_package("mod_wsgi_package") }
73       it { is_expected.to contain_file('wsgi.load').with_content(%r"LoadModule wsgi_module /foo/bar/baz") }
74     end
75     describe "with custom mod_path not containing /" do
76       let :params do
77         {
78           :package_name => 'mod_wsgi_package',
79           :mod_path     => 'wsgi_mod_name.so',
80         }
81       end
82       it { is_expected.to contain_apache__mod('wsgi').with({
83           'path'     => 'modules/wsgi_mod_name.so',
84           'package'  => 'mod_wsgi_package',
85         })
86       }
87       it { is_expected.to contain_file('wsgi.load').with_content(%r"LoadModule wsgi_module modules/wsgi_mod_name.so") }
88
89     end
90     describe "with package_name but no mod_path" do
91       let :params do
92         {
93           :mod_path => '/foo/bar/baz',
94         }
95       end
96       it { expect { catalogue }.to raise_error Puppet::Error, /apache::mod::wsgi - both package_name and mod_path must be specified!/ }
97     end
98     describe "with mod_path but no package_name" do
99       let :params do
100         {
101           :package_name => '/foo/bar/baz',
102         }
103       end
104       it { expect { catalogue }.to raise_error Puppet::Error, /apache::mod::wsgi - both package_name and mod_path must be specified!/ }
105     end
106   end
107   context "on a FreeBSD OS" do
108     let :facts do
109       {
110         :osfamily               => 'FreeBSD',
111         :operatingsystemrelease => '9',
112         :concat_basedir         => '/dne',
113         :operatingsystem        => 'FreeBSD',
114         :id                     => 'root',
115         :kernel                 => 'FreeBSD',
116         :path                   => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
117         :is_pe                  => false,
118       }
119     end
120     it { is_expected.to contain_class("apache::params") }
121     it { is_expected.to contain_class('apache::mod::wsgi').with(
122         'wsgi_socket_prefix' => nil
123       )
124     }
125     it { is_expected.to contain_package("www/mod_wsgi") }
126   end
127   context "on a Gentoo OS" do
128     let :facts do
129       {
130         :osfamily               => 'Gentoo',
131         :operatingsystem        => 'Gentoo',
132         :operatingsystemrelease => '3.16.1-gentoo',
133         :concat_basedir         => '/dne',
134         :id                     => 'root',
135         :kernel                 => 'Linux',
136         :path                   => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin',
137         :is_pe                  => false,
138       }
139     end
140     it { is_expected.to contain_class("apache::params") }
141     it { is_expected.to contain_class('apache::mod::wsgi').with(
142         'wsgi_socket_prefix' => nil
143       )
144     }
145     it { is_expected.to contain_package("www-apache/mod_wsgi") }
146   end
147 end