~ubuntu-branches/ubuntu/vivid/neutron-fwaas/vivid-updates

« back to all changes in this revision

Viewing changes to neutron_fwaas/tests/unit/services/firewall/test_firewall_service.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2015-04-10 09:38:51 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20150410093851-ykz5nmyk3f6e4rnv
Tags: 2015.1~rc1-0ubuntu1
* New upstream milestone release:
  - d/control: Align version requirement with upstream. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2014 OpenStack Foundation.
2
 
# All Rights Reserved.
3
 
#
4
 
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
5
 
#    not use this file except in compliance with the License. You may obtain
6
 
#    a copy of the License at
7
 
#
8
 
#         http://www.apache.org/licenses/LICENSE-2.0
9
 
#
10
 
#    Unless required by applicable law or agreed to in writing, software
11
 
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
 
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
 
#    License for the specific language governing permissions and limitations
14
 
#    under the License.
15
 
 
16
 
import mock
17
 
 
18
 
from neutron.tests import base
19
 
from oslo_config import cfg
20
 
 
21
 
from neutron_fwaas.services.firewall.agents import firewall_service
22
 
 
23
 
FWAAS_NOP_DEVICE = ('neutron_fwaas.tests.unit.services.firewall.agents.'
24
 
                    'test_firewall_agent_api.NoopFwaasDriver')
25
 
 
26
 
 
27
 
class TestFirewallDeviceDriverLoading(base.BaseTestCase):
28
 
 
29
 
    def setUp(self):
30
 
        super(TestFirewallDeviceDriverLoading, self).setUp()
31
 
        self.service = firewall_service.FirewallService(mock.Mock())
32
 
 
33
 
    def test_loading_firewall_device_driver(self):
34
 
        """Get the sole device driver for FWaaS."""
35
 
        cfg.CONF.set_override('driver',
36
 
                              FWAAS_NOP_DEVICE,
37
 
                              'fwaas')
38
 
        driver = self.service.load_device_drivers()
39
 
        self.assertIsNotNone(driver)
40
 
        self.assertIn(driver.__class__.__name__, FWAAS_NOP_DEVICE)
41
 
 
42
 
    def test_fail_no_such_firewall_device_driver(self):
43
 
        """Failure test of import error for FWaaS device driver."""
44
 
        cfg.CONF.set_override('driver',
45
 
                              'no.such.class',
46
 
                              'fwaas')
47
 
        self.assertRaises(ImportError,
48
 
                          self.service.load_device_drivers)
49
 
 
50
 
    def test_fail_firewall_no_device_driver_specified(self):
51
 
        """Failure test when no FWaaS device driver is specified.
52
 
 
53
 
        This is a configuration error, as the user must specify a device
54
 
        driver, when enabling the firewall service (and there is no default
55
 
        configuration set. We'll simulate that by using an empty string.
56
 
        """
57
 
        cfg.CONF.set_override('driver',
58
 
                              '',
59
 
                              'fwaas')
60
 
        self.assertRaises(ValueError,
61
 
                          self.service.load_device_drivers)