Ticket #5923: required-forms-count-field-tests.diff

File required-forms-count-field-tests.diff, 6.1 KB (added by jakub_vysoky, 17 years ago)

django tests to work with this ticket

  • tests/modeltests/model_formsets/models.py

    diff --git a/tests/modeltests/model_formsets/models.py b/tests/modeltests/model_formsets/models.py
    index cac73d7..e3fce2f 100644
    a b __test__ = {'API_TESTS': """  
    3030
    3131>>> data = {
    3232...     'form-COUNT': '3',
     33...     'form-REQUIRED': '0', # number of forms filled before
    3334...     'form-0-name': 'Charles Baudelaire',
    3435...     'form-1-name': 'Arthur Rimbaud',
    3536...     'form-2-name': '',
    but in that case we'll use it to display them in alphabetical order by name.  
    6667
    6768>>> data = {
    6869...     'form-COUNT': '3',
     70...     'form-REQUIRED': '2', # number of forms filled before
    6971...     'form-0-id': '2',
    7072...     'form-0-name': 'Arthur Rimbaud',
    7173...     'form-1-id': '1',
    deltetion, make sure we don't save that form.  
    107109
    108110>>> data = {
    109111...     'form-COUNT': '4',
     112...     'form-REQUIRED': '3', # number of forms filled before
    110113...     'form-0-id': '2',
    111114...     'form-0-name': 'Arthur Rimbaud',
    112115...     'form-1-id': '1',
    admin system's edit inline functionality works.  
    148151
    149152>>> data = {
    150153...     'book_set-COUNT': '3',
     154...     'book_set-REQUIRED': '0', # number of forms filled before
    151155...     'book_set-0-title': 'Les Fleurs du Mal',
    152156...     'book_set-1-title': '',
    153157...     'book_set-2-title': '',
    book.  
    181185
    182186>>> data = {
    183187...     'book_set-COUNT': '3',
     188...     'book_set-REQUIRED': '1', # number of forms filled before
    184189...     'book_set-0-id': '1',
    185190...     'book_set-0-title': 'Les Fleurs du Mal',
    186191...     'book_set-1-title': 'Le Spleen de Paris',
  • tests/regressiontests/forms/formsets.py

    diff --git a/tests/regressiontests/forms/formsets.py b/tests/regressiontests/forms/formsets.py
    index a6da2fe..6c1cb6d 100644
    a b the COUNT field appropriately.  
    3333
    3434>>> data = {
    3535...     'choices-COUNT': '1', # the number of forms rendered
     36...     'choices-REQUIRED': '0', # number of forms filled before
    3637...     'choices-0-choice': 'Calexico',
    3738...     'choices-0-votes': '100',
    3839... }
    any of the forms.  
    5859
    5960>>> data = {
    6061...     'choices-COUNT': '1', # the number of forms rendered
     62...     'choices-REQUIRED': '1', # number of forms filled before
     63...     'choices-REQUIRED': '0', # number of forms filled before
    6164...     'choices-0-choice': 'Calexico',
    6265...     'choices-0-votes': '',
    6366... }
    Let's simulate what would happen if we submitted this form.  
    9497
    9598>>> data = {
    9699...     'choices-COUNT': '2', # the number of forms rendered
     100...     'choices-REQUIRED': '1', # number of forms filled before
    97101...     'choices-0-choice': 'Calexico',
    98102...     'choices-0-votes': '100',
    99103...     'choices-1-choice': '',
    handle that later.  
    114118
    115119>>> data = {
    116120...     'choices-COUNT': '2', # the number of forms rendered
     121...     'choices-REQUIRED': '1', # number of forms filled before
    117122...     'choices-0-choice': 'Calexico',
    118123...     'choices-0-votes': '100',
    119124...     'choices-1-choice': 'The Decemberists',
    handle that case later.  
    133138
    134139>>> data = {
    135140...     'choices-COUNT': '2', # the number of forms rendered
     141...     'choices-REQUIRED': '1', # number of forms filled before
    136142...     'choices-0-choice': '', # deleted value
    137143...     'choices-0-votes': '', # deleted value
    138144...     'choices-1-choice': '',
    number of forms to be completed.  
    169175
    170176>>> data = {
    171177...     'choices-COUNT': '3', # the number of forms rendered
     178...     'choices-REQUIRED': '0', # number of forms filled before
    172179...     'choices-0-choice': '',
    173180...     'choices-0-votes': '',
    174181...     'choices-1-choice': '',
    We can just fill out one of the forms.  
    188195
    189196>>> data = {
    190197...     'choices-COUNT': '3', # the number of forms rendered
     198...     'choices-REQUIRED': '0', # number of forms filled before
    191199...     'choices-0-choice': 'Calexico',
    192200...     'choices-0-votes': '100',
    193201...     'choices-1-choice': '',
    And once again, if we try to partially complete a form, validation will fail.  
    207215
    208216>>> data = {
    209217...     'choices-COUNT': '3', # the number of forms rendered
     218...     'choices-REQUIRED': '0', # number of forms filled before
    210219...     'choices-0-choice': 'Calexico',
    211220...     'choices-0-votes': '100',
    212221...     'choices-1-choice': 'The Decemberists',
    get an error.  
    244253
    245254>>> data = {
    246255...     'choices-COUNT': '3', # the number of forms rendered
     256...     'choices-REQUIRED': '1', # number of forms filled before
    247257...     'choices-0-choice': 'Calexico',
    248258...     'choices-0-votes': '100',
    249259...     'choices-1-choice': '',
    To delete something, we just need to set that form's special delete field to  
    289299
    290300>>> data = {
    291301...     'choices-COUNT': '3', # the number of forms rendered
     302...     'choices-REQUIRED': '2', # number of forms filled before
    292303...     'choices-0-choice': 'Calexico',
    293304...     'choices-0-votes': '100',
    294305...     'choices-0-DELETE': '',
    something at the front of the list, you'd need to set it's order to 0.  
    336347
    337348>>> data = {
    338349...     'choices-COUNT': '3', # the number of forms rendered
     350...     'choices-REQUIRED': '2', # number of forms filled before
    339351...     'choices-0-choice': 'Calexico',
    340352...     'choices-0-votes': '100',
    341353...     'choices-0-ORDER': '1',
    Let's delete Fergie, and put The Decemberists ahead of Calexico.  
    391403
    392404>>> data = {
    393405...     'choices-COUNT': '4', # the number of forms rendered
     406...     'choices-REQUIRED': '3', # number of forms filled before
    394407...     'choices-0-choice': 'Calexico',
    395408...     'choices-0-votes': '100',
    396409...     'choices-0-ORDER': '1',
    We start out with a some duplicate data.  
    451464
    452465>>> data = {
    453466...     'drinks-COUNT': '2',
     467...     'drinks-REQUIRED': '0', # number of forms filled before
    454468...     'drinks-0-name': 'Gin and Tonic',
    455469...     'drinks-1-name': 'Gin and Tonic',
    456470... }
    Make sure we didn't break the valid case.  
    471485
    472486>>> data = {
    473487...     'drinks-COUNT': '2',
     488...     'drinks-REQUIRED': '0', # number of forms filled before
    474489...     'drinks-0-name': 'Gin and Tonic',
    475490...     'drinks-1-name': 'Bloody Mary',
    476491... }
Back to Top