Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added more tests to custom_pk unit-test model

git-svn-id: http://code.djangoproject.com/svn/django/trunk@461 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 63e1f3d39c0ef19b022675da2b138a3ba4cb0119 1 parent 7bac552
Adrian Holovaty authored August 10, 2005

Showing 1 changed file with 24 additions and 2 deletions. Show diff stats Hide diff stats

  1. 26  tests/testapp/models/custom_pk.py
26  tests/testapp/models/custom_pk.py
@@ -16,13 +16,35 @@ class Employee(meta.Model):
16 16
         meta.CharField('first_name', maxlength=20),
17 17
         meta.CharField('last_name', maxlength=20),
18 18
     )
  19
+    ordering = ('last_name', 'first_name')
19 20
 
20 21
     def __repr__(self):
21 22
         return "%s %s" % (self.first_name, self.last_name)
22 23
 
23 24
 API_TESTS = """
24  
->>> e = employees.Employee(employee_code='ABC123', first_name='Dan', last_name='Jones')
25  
->>> e.save()
  25
+>>> dan = employees.Employee(employee_code='ABC123', first_name='Dan', last_name='Jones')
  26
+>>> dan.save()
26 27
 >>> employees.get_list()
27 28
 [Dan Jones]
  29
+
  30
+>>> fran = employees.Employee(employee_code='XYZ456', first_name='Fran', last_name='Bones')
  31
+>>> fran.save()
  32
+>>> employees.get_list()
  33
+[Fran Bones, Dan Jones]
  34
+
  35
+>>> employees.get_object(pk='ABC123')
  36
+Dan Jones
  37
+>>> employees.get_object(pk='XYZ456')
  38
+Fran Bones
  39
+>>> employees.get_object(pk='foo')
  40
+Traceback (most recent call last):
  41
+    ...
  42
+EmployeeDoesNotExist: Employee does not exist for {'pk': 'foo'}
  43
+
  44
+# Fran got married and changed her last name.
  45
+>>> fran = employees.get_object(pk='XYZ456')
  46
+>>> fran.last_name = 'Jones'
  47
+>>> fran.save()
  48
+>>> employees.get_list(last_name__exact='Jones')
  49
+[Dan Jones, Fran Jones]
28 50
 """

0 notes on commit 63e1f3d

Please sign in to comment.
Something went wrong with that request. Please try again.