summaryrefslogtreecommitdiff
path: root/django-openstack/django_openstack/tests/context_processor_tests.py
blob: 335845861f02c759d0bff84b8923c1effcdc115e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from django_openstack import context_processors, test


class ContextProcessorTests(test.TestCase):
    def setUp(self):
        super(ContextProcessorTests, self).setUp()
        self._prev_catalog = self.request.user.service_catalog

    def tearDown(self):
        super(ContextProcessorTests, self).tearDown()
        self.request.user.service_catalog = self._prev_catalog

    def test_object_store(self):
        # Returns the object store service data when it's in the catalog
        object_store = context_processors.object_store(self.request)
        self.assertNotEqual(None, object_store['object_store_configured'])

        # Returns None when the object store is not in the catalog
        new_catalog = [service for service in self.request.user.service_catalog
                            if service['type'] != 'object-store']
        self.request.user.service_catalog = new_catalog
        object_store = context_processors.object_store(self.request)
        self.assertEqual(None, object_store['object_store_configured'])