File: testing.rst

package info (click to toggle)
python-oslo.limit 2.6.1-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 348 kB
  • sloc: python: 1,078; makefile: 25; sh: 2
file content (30 lines) | stat: -rw-r--r-- 750 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
=======
Testing
=======

To test a project that uses oslo.limit, a fixture is provided. This
mocks out the connection to keystone and retrieval of registered and
project limits.

Example
=======

.. code-block:: python

   from oslo_limit import fixture

   class MyTest(unittest.TestCase):
       def setUp(self):
           super(MyTest, self).setUp()

           # Default limit of 10 widgets
           registered_limits = {'widgets': 10}

           # project2 gets 20 widgets
           project_limits = {'project2': {'widgets': 20}}

           self.useFixture(fixture.LimitFixture(registered_limits,
                                                project_limits))

       def test_thing(self):
           # ... use limit.Enforcer() as usual