PageRenderTime 32ms CodeModel.GetById 26ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/modeltests/custom_methods/tests.py

https://code.google.com/p/mango-py/
Python | 42 lines | 36 code | 6 blank | 0 comment | 0 complexity | 66412bab3ecdbdcd818d2a80039cff5f MD5 | raw file
 1from datetime import date
 2
 3from django.test import TestCase
 4
 5from models import Article
 6
 7
 8class MethodsTests(TestCase):
 9    def test_custom_methods(self):
10        a = Article.objects.create(
11            headline="Area man programs in Python", pub_date=date(2005, 7, 27)
12        )
13        b = Article.objects.create(
14            headline="Beatles reunite", pub_date=date(2005, 7, 27)
15        )
16
17        self.assertFalse(a.was_published_today())
18        self.assertQuerysetEqual(
19            a.articles_from_same_day_1(), [
20                "Beatles reunite",
21            ],
22            lambda a: a.headline,
23        )
24        self.assertQuerysetEqual(
25            a.articles_from_same_day_2(), [
26                "Beatles reunite",
27            ],
28            lambda a: a.headline
29        )
30
31        self.assertQuerysetEqual(
32            b.articles_from_same_day_1(), [
33                "Area man programs in Python",
34            ],
35            lambda a: a.headline,
36        )
37        self.assertQuerysetEqual(
38            b.articles_from_same_day_2(), [
39                "Area man programs in Python",
40            ],
41            lambda a: a.headline
42        )