Django

Code

Changeset 5741

Show
Ignore:
Timestamp:
07/21/07 00:17:20 (1 year ago)
Author:
russellm
Message:

Fixed #4402 -- Modified test client to allow multi-valued inputs on GET requests. Thanks for the suggestion, eddymul@gmail.com.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/test/client.py

    r5699 r5741  
    196196            'CONTENT_TYPE':    'text/html; charset=utf-8', 
    197197            'PATH_INFO':       path, 
    198             'QUERY_STRING':    urlencode(data), 
     198            'QUERY_STRING':    urlencode(data, doseq=True), 
    199199            'REQUEST_METHOD': 'GET', 
    200200        } 
  • django/trunk/django/utils/http.py

    r5609 r5741  
    3131    if hasattr(query, 'items'): 
    3232        query = query.items() 
    33     return urllib.urlencode([(smart_str(k), smart_str(v)) for k, 
    34         v in query], doseq) 
     33    return urllib.urlencode( 
     34        [(smart_str(k), 
     35         isinstance(v, (list,tuple)) and [smart_str(i) for i in v] or smart_str(v)) 
     36            for k, v in query], 
     37        doseq) 
    3538 
  • django/trunk/tests/modeltests/test_client/models.py

    r5677 r5741  
    123123        self.assertTemplateUsed(response, "Valid POST Template") 
    124124 
     125    def test_valid_form_with_hints(self): 
     126        "GET a form, providing hints in the GET data" 
     127        hints = { 
     128            'text': 'Hello World', 
     129            'multi': ('b','c','e') 
     130        } 
     131        response = self.client.get('/test_client/form_view/', data=hints) 
     132        self.assertEqual(response.status_code, 200) 
     133        self.assertTemplateUsed(response, "Form GET Template") 
     134        # Check that the multi-value data has been rolled out ok 
     135        self.assertContains(response, 'Select a valid choice.', 0) 
     136         
    125137    def test_incomplete_data_form(self): 
    126138        "POST incomplete data to a form" 
  • django/trunk/tests/modeltests/test_client/views.py

    r5609 r5741  
    8585            c = Context({'form': form}) 
    8686    else: 
    87         form = TestForm(
     87        form = TestForm(request.GET
    8888        t = Template('Viewing base form. {{ form }}.', name='Form GET Template') 
    8989        c = Context({'form': form}) 
     
    108108        } 
    109109    ) 
    110  
    111110         
    112111def login_protected_view(request):