Django

Code

Changeset 3031

Show
Ignore:
Timestamp:
05/31/06 14:23:07 (2 years ago)
Author:
adrian
Message:

Cleaned up numbering with model unit tests

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/tests/modeltests/field_defaults/models.py

    r2809 r3031  
    11""" 
    2 XXX. Callable defaults 
     231. Callable defaults 
    33 
    4 ??? 
     4You can pass callable objects as the ``default`` parameter to a field. When 
     5the object is created without an explicit value passed in, Django will call 
     6the method to determine the default value. 
     7 
     8This example uses ``datetime.datetime.now`` as the default for the ``pub_date`` 
     9field. 
    510""" 
    611 
     
    1015class Article(models.Model): 
    1116    headline = models.CharField(maxlength=100, default='Default headline') 
    12     pub_date = models.DateTimeField(default = datetime.now) 
    13      
    14     def __repr__(self): 
     17    pub_date = models.DateTimeField(default=datetime.now) 
     18 
     19    def __str__(self): 
    1520        return self.headline 
    1621 
     
    4449>>> d.seconds < 5 
    4550True 
    46  
    47  
    4851""" 
  • django/trunk/tests/modeltests/m2m_and_m2o/models.py

    r3030 r3031  
    11""" 
    2 27. Many-to-many and many-to-one relationships to the same table 
     228. Many-to-many and many-to-one relationships to the same table 
    33 
    4 This is a response to bug #1535 
    5  
     4Make sure to set ``related_name`` if you use relationships to the same table. 
    65""" 
    76 
     
    1514    cc = models.ManyToManyField(User, blank=True, related_name='test_issue_cc') 
    1615    client = models.ForeignKey(User, related_name='test_issue_client') 
    17     def __repr__(self): 
    18         return "<Issue %d>" % (self.num,) 
     16 
     17    def __str__(self): 
     18        return str(self.num) 
    1919 
    2020    class Meta: 
  • django/trunk/tests/modeltests/m2m_recursive/models.py

    r2809 r3031  
    11""" 
    2 26. Many-to-many relationships between the same two tables 
     227. Many-to-many relationships between the same two tables 
    33 
    4 In this example, A Person can have many friends, who are also people. Friendship is a  
     4In this example, A Person can have many friends, who are also people. Friendship is a 
    55symmetrical relationshiup - if I am your friend, you are my friend. 
    66 
    77A person can also have many idols - but while I may idolize you, you may not think 
    8 the same of me. 'Idols' is an example of a non-symmetrical m2m field. Only recursive  
     8the same of me. 'Idols' is an example of a non-symmetrical m2m field. Only recursive 
    99m2m fields may be non-symmetrical, and they are symmetrical by default. 
    1010 
    1111This test validates that the m2m table will create a mangled name for the m2m table if 
    12 there will be a clash, and tests that symmetry is preserved where appropriate.  
     12there will be a clash, and tests that symmetry is preserved where appropriate. 
    1313""" 
    1414 
     
    4141 
    4242# Who is friends with Anne? 
    43 >>> a.friends.all()  
     43>>> a.friends.all() 
    4444[Bill, Chuck, David] 
    4545 
     
    5353 
    5454# Who is friends with David? 
    55 >>> d.friends.all()  
     55>>> d.friends.all() 
    5656[Anne, Chuck] 
    5757 
     
    6060 
    6161# Who is friends with Anne? 
    62 >>> a.friends.all()  
     62>>> a.friends.all() 
    6363[Bill, Chuck, David] 
    6464 
     
    7171 
    7272# Who is friends with Anne? 
    73 >>> a.friends.all()  
     73>>> a.friends.all() 
    7474[Chuck, David] 
    7575 
     
    8282 
    8383# Who is friends with Anne? 
    84 >>> a.friends.all()  
     84>>> a.friends.all() 
    8585[] 
    8686 
     
    9191 
    9292# Who is friends with David? 
    93 >>> d.friends.all()  
     93>>> d.friends.all() 
    9494[Chuck] 
    9595 
     
    106106 
    107107# Who are Anne's idols? 
    108 >>> a.idols.all()  
     108>>> a.idols.all() 
    109109[Bill, Chuck, David] 
    110110 
     
    141141 
    142142# Who are Anne's idols? 
    143 >>> a.idols.all()  
     143>>> a.idols.all() 
    144144[Bill, Chuck, David] 
    145145 
     
    159159 
    160160# Who are Anne's idols? 
    161 >>> a.idols.all()  
     161>>> a.idols.all() 
    162162[Chuck, David] 
    163163 
     
    178178 
    179179# Who are Anne's idols 
    180 >>> a.idols.all()  
     180>>> a.idols.all() 
    181181[] 
    182182 
     
    187187 
    188188# Who is friends with David? 
    189 >>> d.stalkers.all()  
     189>>> d.stalkers.all() 
    190190[Chuck] 
    191191 
  • django/trunk/tests/modeltests/manipulators/models.py

    r3028 r3031  
    11""" 
    2 25. Default manipulators 
     226. Default manipulators 
    33 
    44Each model gets an AddManipulator and ChangeManipulator by default. 
  • django/trunk/tests/modeltests/pagination/models.py

    r3030 r3031  
    11""" 
    2 28. Object pagination 
     229. Object pagination 
    33 
    44Django provides a framework for paginating a list of objects in a few lines 
  • django/trunk/tests/modeltests/validation/models.py

    r3030 r3031  
    11""" 
    2 29. Validation 
     230. Validation 
    33 
    44This is an experimental feature!