diff options
| author | Barry Warsaw | 2011-04-12 18:09:36 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2011-04-12 18:09:36 -0400 |
| commit | 5bb93de8db9b251a53968f0e1cf0b22d472e1a57 (patch) | |
| tree | aac85174fe3cea5e09113b9c9293fc484c773a66 /src/mailman/testing/layers.py | |
| parent | 980e9dff9811466dcb9b44539d694b6eac32a17b (diff) | |
| parent | 7c6633d17617ac60f11ff7de44160a9d804d4777 (diff) | |
| download | mailman-5bb93de8db9b251a53968f0e1cf0b22d472e1a57.tar.gz mailman-5bb93de8db9b251a53968f0e1cf0b22d472e1a57.tar.zst mailman-5bb93de8db9b251a53968f0e1cf0b22d472e1a57.zip | |
Lots of work to update the model for users, passwords, membership, testing,
and the REST API. A highlight of the merged changes:
* The REST API now has a /users top-level URL under which user information can
be accessed, and new users can be created.
* IUsers now have a unique `user_id` which is evident in the REST API. Under
testing, these uids are predictable, but otherwise, they're entirely random
but guaranteed to be unique.
* IUsers now have a `created_on` attribute. Like `user_id` these are
predictable under testing, but otherwise reflect the actual date.
* User passwords are now 'encrypted' (hashed) as defined by the config file.
- new mailman.cfg variables password_scheme and password_length
* IMember gets a `user` attribute which is a convenience for getting the IUser
associated with the member.
* mmsitepass is gone:
- creator_pw_file
- site_pw_file
* Improved test initialization and its hook into zc.buildout.
Diffstat (limited to 'src/mailman/testing/layers.py')
| -rw-r--r-- | src/mailman/testing/layers.py | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/src/mailman/testing/layers.py b/src/mailman/testing/layers.py index 353dd9edd..29ab7169a 100644 --- a/src/mailman/testing/layers.py +++ b/src/mailman/testing/layers.py @@ -25,6 +25,7 @@ __all__ = [ 'MockAndMonkeyLayer', 'RESTLayer', 'SMTPLayer', + 'is_testing', ] @@ -48,7 +49,6 @@ from mailman.core.logging import get_handler from mailman.interfaces.domain import IDomainManager from mailman.testing.helpers import TestableMaster, reset_the_world from mailman.testing.mta import ConnectionCountingController -from mailman.utilities.datetime import factory from mailman.utilities.string import expand @@ -60,17 +60,20 @@ NL = '\n' class MockAndMonkeyLayer: """Layer for mocking and monkey patching for testing.""" - @classmethod - def setUp(cls): - factory.testing_mode = True + # Set this to True to enable predictable datetimes, uids, etc. + testing_mode = False - @classmethod - def tearDown(cls): - factory.testing_mode = False + # A registration of all testing factories, for resetting between tests. + _resets = [] @classmethod def testTearDown(cls): - factory.reset() + for reset in cls._resets: + reset() + + @classmethod + def register_reset(cls, reset): + cls._resets.append(reset) @@ -102,8 +105,12 @@ class ConfigLayer(MockAndMonkeyLayer): test_config = dedent(""" [mailman] layout: testing + [passwords] + password_scheme: cleartext [paths.testing] var_dir: %s + [devmode] + testing: yes """ % cls.var_dir) # Read the testing config and push it. test_config += resource_string('mailman.testing', 'testing.cfg') @@ -286,3 +293,13 @@ class RESTLayer(SMTPLayer): assert cls.server is not None, 'Layer not set up' cls.server.stop() cls.server = None + + + +def is_testing(): + """Return a 'testing' flag for use with the predictable factories. + + :return: True when in testing mode. + :rtype: bool + """ + return MockAndMonkeyLayer.testing_mode or config.devmode.testing |
