Changeset 10037


Ignore:
Timestamp:
18 Mar 2013, 10:34:07 (12 years ago)
Author:
Henrik Bettermann
Message:

Add another test which checks the xml response.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_webservices.py

    r10036 r10037  
    6666        return
    6767
    68     REQUEST_XML="""\
     68    def test_XMLRPC_post_1(self):
     69        REQUEST_XML="""\
    6970<?xml version="1.0"?>
    7071<methodCall>
     
    7677</params>
    7778</methodCall>"""
    78 
    79     RESPONSE_XML="""\
     79        RESPONSE_XML="""\
    8080<?xml version='1.0'?>
    8181<methodResponse>
     
    8787</methodResponse>
    8888"""
    89 
    90     def test_XMLRPC_post(self):
    9189        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    92         self.browser.addHeader('Content-Length', len(self.REQUEST_XML))
    93         self.browser.post('http://localhost/app', self.REQUEST_XML,
     90        self.browser.addHeader('Content-Length', len(REQUEST_XML))
     91        self.browser.post('http://localhost/app', REQUEST_XML,
    9492            'text/xml; charset=utf-8')
    95         self.assertEqual(self.browser.contents, self.RESPONSE_XML)
     93        self.assertEqual(self.browser.contents, RESPONSE_XML)
     94        return
    9695
    9796    def test_get_courses_by_session(self):
     
    109108            {'100|CRS1': 'Course 1', '100|COURSE1': 'Unnamed Course'})
    110109        return
     110
     111    def test_XMLRPC_post_2(self):
     112        self.setup_student(self.student)
     113        REQUEST_XML="""\
     114<?xml version="1.0"?>
     115<methodCall>
     116<methodName>get_courses_by_session</methodName>
     117<params>
     118<param>
     119<value><string>K1000000</string></value>
     120</param>
     121</params>
     122</methodCall>"""
     123        RESPONSE_XML="""\
     124<?xml version='1.0'?>
     125<methodResponse>
     126<params>
     127<param>
     128<value><struct>
     129<member>
     130<name>100|CRS1</name>
     131<value><string>Course 1</string></value>
     132</member>
     133<member>
     134<name>100|COURSE1</name>
     135<value><string>Unnamed Course</string></value>
     136</member>
     137</struct></value>
     138</param>
     139</params>
     140</methodResponse>
     141"""
     142        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     143        self.browser.addHeader('Content-Length', len(REQUEST_XML))
     144        self.browser.post('http://localhost/app', REQUEST_XML,
     145            'text/xml; charset=utf-8')
     146        self.assertEqual(self.browser.contents, RESPONSE_XML)
     147        return
Note: See TracChangeset for help on using the changeset viewer.