diff --git a/src/postorius/doc/_build/doctrees/development.doctree b/src/postorius/doc/_build/doctrees/development.doctree
new file mode 100644
index 0000000..9a2b220
--- /dev/null
+++ b/src/postorius/doc/_build/doctrees/development.doctree
Binary files differ
diff --git a/src/postorius/doc/_build/doctrees/environment.pickle b/src/postorius/doc/_build/doctrees/environment.pickle
index f91fb9a..46cb22a 100644
--- a/src/postorius/doc/_build/doctrees/environment.pickle
+++ b/src/postorius/doc/_build/doctrees/environment.pickle
Binary files differ
diff --git a/src/postorius/doc/_build/doctrees/index.doctree b/src/postorius/doc/_build/doctrees/index.doctree
index 26e23ff..6d5cf98 100644
--- a/src/postorius/doc/_build/doctrees/index.doctree
+++ b/src/postorius/doc/_build/doctrees/index.doctree
Binary files differ
diff --git a/src/postorius/doc/_build/doctrees/news.doctree b/src/postorius/doc/_build/doctrees/news.doctree
index 8f07463..ab3c398 100644
--- a/src/postorius/doc/_build/doctrees/news.doctree
+++ b/src/postorius/doc/_build/doctrees/news.doctree
Binary files differ
diff --git a/src/postorius/doc/_build/doctrees/setup.doctree b/src/postorius/doc/_build/doctrees/setup.doctree
index 5bba5e4..f7cfe80 100644
--- a/src/postorius/doc/_build/doctrees/setup.doctree
+++ b/src/postorius/doc/_build/doctrees/setup.doctree
Binary files differ
diff --git a/src/postorius/doc/_build/doctrees/testing.doctree b/src/postorius/doc/_build/doctrees/testing.doctree
new file mode 100644
index 0000000..c3dc290
--- /dev/null
+++ b/src/postorius/doc/_build/doctrees/testing.doctree
Binary files differ
diff --git a/src/postorius/doc/_build/doctrees/using.doctree b/src/postorius/doc/_build/doctrees/using.doctree
index 76c1ffc..4c70903 100644
--- a/src/postorius/doc/_build/doctrees/using.doctree
+++ b/src/postorius/doc/_build/doctrees/using.doctree
Binary files differ
diff --git a/src/postorius/doc/_build/html/_sources/development.txt b/src/postorius/doc/_build/html/_sources/development.txt
new file mode 100644
index 0000000..45efe00
--- /dev/null
+++ b/src/postorius/doc/_build/html/_sources/development.txt
@@ -0,0 +1,89 @@
+===========
+Development
+===========
+
+
+Testing
+=======
+
+All test modules reside in the ``postorius/src/postorius/tests`` directory
+and this is where you should put your own tests, too. To make the django test
+runner find your tests, make sure to add them to the folder's ``__init__.py``:
+
+::
+
+ from postorius.tests import test_utils
+ from postorius.tests.test_list_members import ListMembersViewTest
+ from postorius.tests.test_list_settings import ListSettingsViewTest
+ from postorius.tests.my_own_tests import MyOwnUnitTest
+
+ __test__ = {
+ "Test Utils": test_utils,
+ "List Members": ListMembersViewTest,
+ "List Settings": ListSettingsViewTest,
+ "My Own Test": MyOwnUnitTest,
+ }
+
+
+``postorius.*`` imports in test modules
+---------------------------------------
+
+When writing unittests make sure that any ``postorius.*`` imports are made
+at the test method level and not at the module level. Here's why:
+
+The Postorius documentation (the one you are reading right now) imports some
+doctest modules from the test package using Sphinx's autodoc extension. This is
+a very nice feature, but in this scenario it has the nasty side effect of
+breaking the build process if application code is imported as well (it will
+fail to find an environment variable that Django needs to run). This can be
+easily prevented by avoiding module level imports of postorius code in the test
+modules.
+
+Good:
+
+::
+
+ from django.utils import unittest
+ from mock import patch
+
+
+ class SomeTest(unittest.TestCase):
+
+ def test_some_method(self):
+ from postorius.views import SomeViewClass
+ foo = 'bar'
+
+Bad:
+
+::
+
+ from django.utils import unittest
+ from mock import patch
+ from postorius.views import SomeViewClass
+
+
+ class SomeTest(unittest.TestCase):
+
+ def test_some_method(self):
+ foo = 'bar'
+
+
+
+Mocking
+-------
+
+Postorius uses Michael Foord's ``mock`` library for mocking. There are some
+shortcuts you can use to quickly create mock objects that behave a little bit like
+objects retreived from mailman.client, like:
+
+- Domains
+- Mailing Lists
+- Users
+- Memberships
+- Addresses
+
+
+Mocking mailman.client objects
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. automodule:: postorius.tests.test_utils
diff --git a/src/postorius/doc/_build/html/_sources/index.txt b/src/postorius/doc/_build/html/_sources/index.txt
index b6027ff..da81de8 100644
--- a/src/postorius/doc/_build/html/_sources/index.txt
+++ b/src/postorius/doc/_build/html/_sources/index.txt
@@ -8,5 +8,5 @@
news.rst
setup.rst
- using.rst
+ development.rst
diff --git a/src/postorius/doc/_build/html/_sources/news.txt b/src/postorius/doc/_build/html/_sources/news.txt
index f717c70..358c245 100644
--- a/src/postorius/doc/_build/html/_sources/news.txt
+++ b/src/postorius/doc/_build/html/_sources/news.txt
@@ -2,22 +2,22 @@
News / Changelog
================
-Copyright (C) 1998-2012 by the Free Software Foundation, Inc.
+Copyright (C) 2012 by the Free Software Foundation, Inc.
-The postorius Django app provides a web user interface to
+The Postorius Django app provides a web user interface to
access GNU Mailman.
-postorius is free software: you can redistribute it and/or
+Postorius is free software: you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, version 3 of the License.
-postorius is distributed in the hope that it will be useful,
+Postorius is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with postorius. If not, see
All test modules reside in the postorius/src/postorius/tests directory +and this is where you should put your own tests, too. To make the django test +runner find your tests, make sure to add them to the folder’s __init__.py:
+from postorius.tests import test_utils
+from postorius.tests.test_list_members import ListMembersViewTest
+from postorius.tests.test_list_settings import ListSettingsViewTest
+from postorius.tests.my_own_tests import MyOwnUnitTest
+
+__test__ = {
+ "Test Utils": test_utils,
+ "List Members": ListMembersViewTest,
+ "List Settings": ListSettingsViewTest,
+ "My Own Test": MyOwnUnitTest,
+}
+
When writing unittests make sure that any postorius.* imports are made +at the test method level and not at the module level. Here’s why:
+The Postorius documentation (the one you are reading right now) imports some +doctest modules from the test package using Sphinx’s autodoc extension. This is +a very nice feature, but in this scenario it has the nasty side effect of +breaking the build process if application code is imported as well (it will +fail to find an environment variable that Django needs to run). This can be +easily prevented by avoiding module level imports of postorius code in the test +modules.
+Good:
+from django.utils import unittest
+from mock import patch
+
+
+class SomeTest(unittest.TestCase):
+
+ def test_some_method(self):
+ from postorius.views import SomeViewClass
+ foo = 'bar'
+
Bad:
+from django.utils import unittest
+from mock import patch
+from postorius.views import SomeViewClass
+
+
+class SomeTest(unittest.TestCase):
+
+ def test_some_method(self):
+ foo = 'bar'
+
Postorius uses Michael Foord’s mock library for mocking. There are some +shortcuts you can use to quickly create mock objects that behave a little bit like +objects retreived from mailman.client, like:
+postorius.tests.utils.create_mock_list creates a mock domain object:
+>>> properties = dict(contact_address='postmaster@example.org',
+... description='Example dot Org',
+... mail_host='example.org',
+... url_host='www.example.org')
+>>> mock_domain = create_mock_domain(properties)
+>>> print mock_domain
+<MagicMock name='Domain' id='...'>
+>>> print mock_domain.contact_address
+postmaster@example.org
+>>> print mock_domain.description
+Example dot Org
+>>> print mock_domain.mail_host
+example.org
+>>> print mock_domain.url_host
+www.example.org
+
postorius.tests.utils.create_mock_list creates a mock list object:
+>>> properties = dict(fqdn_listname='testlist@example.org',
+... mail_host='example.org',
+... list_name='testlist',
+... display_name='Test List')
+>>> mock_list = create_mock_list(properties)
+>>> print mock_list
+<MagicMock name='List' id='...'>
+>>> print mock_list.fqdn_listname
+testlist@example.org
+>>> print mock_list.mail_host
+example.org
+>>> print mock_list.list_name
+testlist
+>>> print mock_list.display_name
+Test List
+
postorius.tests.utils.create_mock_list creates a mock list object:
+>>> properties = dict(fqdn_listname='testlist@example.org',
+... address='les@example.org',)
+>>> mock_member = create_mock_member(properties)
+>>> print mock_member
+<MagicMock name='Member' id='...'>
+>>> print mock_member.fqdn_listname
+testlist@example.org
+>>> print mock_member.address
+les@example.org
+
|
+
|