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
|