[damned-lies] Pass arguments through person save method and add tests



commit 49d4780cdce6aa9f1ccf185107dc19afcb1f1cea
Author: Claude Paroz <claude 2xlibre net>
Date:   Mon May 17 22:52:45 2010 +0200

    Pass arguments through person save method and add tests

 people/models.py         |    4 ++--
 people/tests/__init__.py |   32 ++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 2 deletions(-)
---
diff --git a/people/models.py b/people/models.py
index 70eaef7..e2eb3f2 100644
--- a/people/models.py
+++ b/people/models.py
@@ -55,11 +55,11 @@ class Person(User):
         for account in accounts:
             account.delete()
 
-    def save(self):
+    def save(self, *args, **kwargs):
         if not self.password or self.password == "!":
             self.password = None
             self.set_unusable_password()
-        super(User, self).save()
+        super(User, self).save(*args, **kwargs)
 
     def activate(self):
         self.activation_key = None
diff --git a/people/tests/__init__.py b/people/tests/__init__.py
new file mode 100644
index 0000000..055440c
--- /dev/null
+++ b/people/tests/__init__.py
@@ -0,0 +1,32 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (c) 2010 Claude Paroz <claude 2xlibre net>
+#
+# This file is part of Damned Lies.
+#
+# Damned Lies is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# Damned Lies 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Damned Lies; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+from django.test import TestCase
+from django.test.client import Client
+from django.core.urlresolvers import reverse
+
+class PeopleTestCase(TestCase):
+
+    def test_register(self):
+        c = Client()
+        response = c.post(reverse('register'),
+                          {'username': u'test01', 'password1': u'1234567',
+                           'password2': u'1234567', 'email': u'test01 example org'})
+        self.assertRedirects(response, reverse('register_success'))



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]