• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zopefoundation / Products.Sessions / 16399689495

05 Apr 2025 07:12AM UTC coverage: 94.731%. Remained the same
16399689495

push

github

dataflake
- vb [ci skip]

146 of 180 branches covered (81.11%)

Branch coverage included in aggregate %.

1526 of 1585 relevant lines covered (96.28%)

0.96 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/Products/Sessions/tests/testInitialization.py
1
##############################################################################
2
#
3
# Copyright (c) 2001, 2002 Zope Foundation and Contributors.
4
# All Rights Reserved.
5
#
6
# This software is subject to the provisions of the Zope Public License,
7
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
8
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
9
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
11
# FOR A PARTICULAR PURPOSE.
12
#
13
##############################################################################
14

15
import os
1✔
16
import shutil
1✔
17
import tempfile
1✔
18
import unittest
1✔
19

20
import Products
1✔
21
from App.config import getConfiguration
1✔
22
from App.config import setConfiguration
1✔
23
from OFS.Application import AppInitializer
1✔
24
from OFS.Application import Application
1✔
25
from Zope2.Startup.options import ZopeWSGIOptions
1✔
26

27

28
test_cfg = """
1✔
29
instancehome {instancehome}
30

31
<zodb_db main>
32
   mount-point /
33
   <mappingstorage>
34
      name mappingstorage
35
   </mappingstorage>
36
</zodb_db>
37

38
<zodb_db temporary>
39
    # Temporary storage database (for sessions)
40
    <temporarystorage>
41
      name temporary storage for sessioning
42
    </temporarystorage>
43
    mount-point /temp_folder
44
    container-class OFS.Folder.Folder
45
</zodb_db>
46
"""
47

48

49
def getApp():
1✔
50
    from App.ZApplication import ZApplicationWrapper
1✔
51
    DB = getConfiguration().dbtab.getDatabase('/')
1✔
52
    return ZApplicationWrapper(DB, 'Application', Application)()
1✔
53

54

55
class TestInitialization(unittest.TestCase):
1✔
56
    """Test the application initialization."""
57

58
    def setUp(self):
1✔
59
        self.original_config = getConfiguration()
1✔
60
        self.TEMPDIR = tempfile.mkdtemp()
1✔
61

62
    def tearDown(self):
1✔
63
        setConfiguration(self.original_config)
1✔
64
        shutil.rmtree(self.TEMPDIR)
1✔
65
        Products.__path__ = [d
1✔
66
                             for d in Products.__path__
67
                             if os.path.exists(d)]
68

69
    def configure(self, text):
1✔
70
        # We have to create a directory of our own since the existence
71
        # of the directory is checked.  This handles this in a
72
        # platform-independent way.
73
        config_path = os.path.join(self.TEMPDIR, 'zope.conf')
1✔
74
        with open(config_path, 'w') as fd:
1✔
75
            fd.write(text.format(instancehome=self.TEMPDIR))
1✔
76

77
        options = ZopeWSGIOptions(config_path)()
1✔
78
        config = options.configroot
1✔
79
        self.assertEqual(config.instancehome, self.TEMPDIR)
1✔
80
        setConfiguration(config)
1✔
81

82
    def getInitializer(self):
1✔
83
        app = getApp()
1✔
84
        return AppInitializer(app)
1✔
85

86
    def test_install_browser_id_manager(self):
1✔
87
        from Products.Sessions.BrowserIdManager import BrowserIdManager
1✔
88
        self.configure(test_cfg)
1✔
89
        initializer = self.getInitializer()
1✔
90
        app = initializer.getApp()
1✔
91
        initializer.install_products()
1✔
92
        self.assertIsInstance(app.browser_id_manager, BrowserIdManager)
1✔
93
        self.assertEqual(app.browser_id_manager.meta_type,
1✔
94
                         'Browser Id Manager')
95

96
    def test_install_session_data_manager(self):
1✔
97
        from Products.Sessions.SessionDataManager import SessionDataManager
1✔
98
        self.configure(test_cfg)
1✔
99
        initializer = self.getInitializer()
1✔
100
        initializer.install_products()
1✔
101
        app = initializer.getApp()
1✔
102
        self.assertIsInstance(app.session_data_manager, SessionDataManager)
1✔
103
        self.assertEqual(app.session_data_manager.meta_type,
1✔
104
                         'Session Data Manager')
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc