Author: PaulM
Date: 2010-06-21 21:53:14 -0500 (Mon, 21 Jun 2010)
New Revision: 13373

Added:
   
django/branches/soc2010/test-refactor/tests/modeltests/custom_methods/tests.py
Modified:
   
django/branches/soc2010/test-refactor/tests/modeltests/custom_methods/models.py
Log:
[soc2010/test-refactor] Updated custom_methods model test to unittests


Modified: 
django/branches/soc2010/test-refactor/tests/modeltests/custom_methods/models.py
===================================================================
--- 
django/branches/soc2010/test-refactor/tests/modeltests/custom_methods/models.py 
    2010-06-21 20:28:47 UTC (rev 13372)
+++ 
django/branches/soc2010/test-refactor/tests/modeltests/custom_methods/models.py 
    2010-06-22 02:53:14 UTC (rev 13373)
@@ -36,24 +36,3 @@
         # The asterisk in "(*row)" tells Python to expand the list into
         # positional arguments to Article().
         return [self.__class__(*row) for row in cursor.fetchall()]
-
-__test__ = {'API_TESTS':"""
-# Create a couple of Articles.
->>> from datetime import date
->>> a = Article(id=None, headline='Area man programs in Python', 
pub_date=date(2005, 7, 27))
->>> a.save()
->>> b = Article(id=None, headline='Beatles reunite', pub_date=date(2005, 7, 
27))
->>> b.save()
-
-# Test the custom methods.
->>> a.was_published_today()
-False
->>> a.articles_from_same_day_1()
-[<Article: Beatles reunite>]
->>> a.articles_from_same_day_2()
-[<Article: Beatles reunite>]
->>> b.articles_from_same_day_1()
-[<Article: Area man programs in Python>]
->>> b.articles_from_same_day_2()
-[<Article: Area man programs in Python>]
-"""}

Added: 
django/branches/soc2010/test-refactor/tests/modeltests/custom_methods/tests.py
===================================================================
--- 
django/branches/soc2010/test-refactor/tests/modeltests/custom_methods/tests.py  
                            (rev 0)
+++ 
django/branches/soc2010/test-refactor/tests/modeltests/custom_methods/tests.py  
    2010-06-22 02:53:14 UTC (rev 13373)
@@ -0,0 +1,26 @@
+from datetime import date
+
+from django.test import TestCase
+
+from models import Article
+
+class CustomMethodsTestCase(TestCase):
+    def test_custom_methods(self):
+        # Create a couple of Articles.
+        a = Article(id=None, headline='Area man programs in Python', 
pub_date=date(2005, 7, 27))
+        a.save()
+        b = Article(id=None, headline='Beatles reunite', pub_date=date(2005, 
7, 27))
+        b.save()
+
+        # Test the custom methods.
+        self.assertFalse(a.was_published_today())
+
+        self.assertQuerysetEqual(a.articles_from_same_day_1(),
+                                 ['<Article: Beatles reunite>'])
+        self.assertQuerysetEqual(a.articles_from_same_day_2(),
+                                 ['<Article: Beatles reunite>'])
+        self.assertQuerysetEqual(b.articles_from_same_day_1(),
+                                 ['<Article: Area man programs in Python>'])
+        self.assertQuerysetEqual(b.articles_from_same_day_2(),
+                                 ['<Article: Area man programs in Python>'])
+

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to