From: Patrick Samson Date: Mon, 17 Dec 2012 20:40:39 +0000 (+0100) Subject: Move some docstring tests to tests.py in anticipation of py3 X-Git-Tag: 3.0.0~11 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=e1bcf389a73f78f935f87b45def56ac25e973827;p=django-postman.git Move some docstring tests to tests.py in anticipation of py3 --- diff --git a/postman/models.py b/postman/models.py index 3018e1b..e43036c 100644 --- a/postman/models.py +++ b/postman/models.py @@ -49,12 +49,6 @@ def get_order_by(query_dict): Argument: ``query_dict``: a dictionary to look for a key dedicated to ordering purpose - >>> get_order_by({}) - - >>> get_order_by({ORDER_BY_KEY: 'f'}) - u'sender__username' - >>> get_order_by({ORDER_BY_KEY: 'D'}) - u'-sent_at' """ if ORDER_BY_KEY in query_dict: code = query_dict[ORDER_BY_KEY] # code may be uppercase or lowercase diff --git a/postman/tests.py b/postman/tests.py index 9bf3f24..0ed24af 100644 --- a/postman/tests.py +++ b/postman/tests.py @@ -65,7 +65,7 @@ from postman.api import pm_broadcast, pm_write # because of reload()'s, do "from postman.forms import xxForm" just before needs from postman.models import ORDER_BY_KEY, ORDER_BY_MAPPER, Message, PendingMessage,\ STATUS_PENDING, STATUS_ACCEPTED, STATUS_REJECTED,\ - get_user_representation + get_order_by, get_user_representation from postman.urls import OPTION_MESSAGES # because of reload()'s, do "from postman.utils import notification" just before needs from postman.utils import format_body, format_subject @@ -1574,11 +1574,11 @@ class TagsTest(BaseTest): t = Template("{% load postman_tags %}{% postman_order_by " + keyword +" %}") r = t.render(Context({'gets': QueryDict(context)} if context else {})) self.assertEqual(r[0], '?') - self.assertEqual(set(r[1:].split('&')), set([k+'='+v for k,v in value_list])) + self.assertEqual(set(r[1:].split('&')), set([k+'='+v for k, v in value_list])) def test_order_by(self): "Test 'postman_order_by'." - for k,v in ORDER_BY_MAPPER.items(): + for k, v in ORDER_BY_MAPPER.items(): self.check_order_by(k, [(ORDER_BY_KEY, v)]) self.check_order_by('subject', [(ORDER_BY_KEY, 's')], ORDER_BY_KEY+'=foo') self.check_order_by('subject', [(ORDER_BY_KEY, 'S')], ORDER_BY_KEY+'=s') @@ -1612,6 +1612,12 @@ class UtilsTest(BaseTest): self.assertEqual(format_subject("Re: foo bar"), "Re: foo bar") self.assertEqual(format_subject("rE: foo bar"), "rE: foo bar") + def test_get_order_by(self): + "Test get_order_by()." + self.assertEqual(get_order_by({}), None) + self.assertEqual(get_order_by({ORDER_BY_KEY: 'f'}), 'sender__{0}'.format(get_user_model().USERNAME_FIELD)) + self.assertEqual(get_order_by({ORDER_BY_KEY: 'D'}), '-sent_at') + def test_get_user_representation(self): "Test get_user_representation()." # no setting