From bac086ba43358c043ae8fea52d30be80323d829a Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Wed, 14 Dec 2005 03:29:58 +0000 Subject: [PATCH] magic-removal: Added 'properties' model unit tests git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1618 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/modeltests/properties/__init__.py | 0 tests/modeltests/properties/models.py | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 tests/modeltests/properties/__init__.py create mode 100644 tests/modeltests/properties/models.py diff --git a/tests/modeltests/properties/__init__.py b/tests/modeltests/properties/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/modeltests/properties/models.py b/tests/modeltests/properties/models.py new file mode 100644 index 0000000000..ac7b6fe72f --- /dev/null +++ b/tests/modeltests/properties/models.py @@ -0,0 +1,20 @@ +""" +22. Using properties on models +""" + +from django.core import meta + +class Person(meta.Model): + first_name = meta.CharField(maxlength=30) + last_name = meta.CharField(maxlength=30) + + def _get_full_name(self): + return "%s %s" % (self.first_name, self.last_name) + full_name = property(_get_full_name) + +API_TESTS = """ +>>> a = Person(first_name='John', last_name='Lennon') +>>> a.save() +>>> a.full_name +John Lennon +"""