PageRenderTime 263ms CodeModel.GetById 171ms app.highlight 4ms RepoModel.GetById 87ms app.codeStats 0ms

/tests/regressiontests/queryset_pickle/tests.py

https://code.google.com/p/mango-py/
Python | 36 lines | 24 code | 12 blank | 0 comment | 0 complexity | 18e403488b3ff5fb8dc0064f20fe0fae MD5 | raw file
 1import pickle
 2import datetime
 3
 4from django.test import TestCase
 5
 6from models import Group, Event, Happening
 7
 8
 9class PickleabilityTestCase(TestCase):
10    def assert_pickles(self, qs):
11        self.assertEqual(list(pickle.loads(pickle.dumps(qs))), list(qs))
12
13    def test_related_field(self):
14        g = Group.objects.create(name="Ponies Who Own Maybachs")
15        self.assert_pickles(Event.objects.filter(group=g.id))
16
17    def test_datetime_callable_default_all(self):
18        self.assert_pickles(Happening.objects.all())
19
20    def test_datetime_callable_default_filter(self):
21        self.assert_pickles(Happening.objects.filter(when=datetime.datetime.now()))
22
23    def test_lambda_as_default(self):
24        self.assert_pickles(Happening.objects.filter(name="test"))
25
26    def test_standalone_method_as_default(self):
27        self.assert_pickles(Happening.objects.filter(number1=1))
28
29    def test_staticmethod_as_default(self):
30        self.assert_pickles(Happening.objects.filter(number2=1))
31
32    def test_classmethod_as_default(self):
33        self.assert_pickles(Happening.objects.filter(number3=1))
34
35    def test_membermethod_as_default(self):
36        self.assert_pickles(Happening.objects.filter(number4=1))