Changeset 16169 for main/waeup.kofa/trunk/src/waeup/kofa/students/tests
- Timestamp:
- 17 Jul 2020, 19:44:47 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_webservices.py
r16112 r16169 2 2 import xmlrpclib 3 3 import os 4 from time import time 4 5 from cStringIO import StringIO 5 6 from zope.app.testing.xmlrpc import ServerProxy … … 799 800 self.assertEqual(xmlout, response) 800 801 return 802 803 def test_get_unpaid_payments(self): 804 timestamp1 = ("%d" % int((time()-10)*10000))[1:] 805 timestamp2 = ("%d" % int((time()-5)*10000))[1:] 806 timestamp3 = ("%d" % int((time()-(3*86400))*10000))[1:] 807 p_id_1 = ("p%s" % timestamp1) 808 p_id_2 = ("p%s" % timestamp2) 809 p_id_3 = ("p%s" % timestamp3) 810 payment1 = StudentOnlinePayment() 811 payment1.p_id = p_id_1 812 payment1.p_session = 2012 813 payment1.amount_auth = 12.12 814 payment1.p_state = u'unpaid' 815 payment1.p_category = u'schoolfee' 816 payment1.r_company = u'xyz' 817 self.student['payments']['my-payment1'] = payment1 818 payment2 = StudentOnlinePayment() 819 payment2.p_id = p_id_2 820 payment2.p_session = 2012 821 payment2.amount_auth = 12.12 822 payment2.p_state = u'paid' 823 payment2.p_category = u'clearance' 824 self.student['payments']['my-payment2'] = payment2 825 payment3 = StudentOnlinePayment() 826 payment3.p_id = p_id_3 827 payment3.p_session = 2012 828 payment3.amount_auth = 12.12 829 payment3.p_state = u'unpaid' 830 payment3.p_category = u'schoolfee' 831 self.student['payments']['my-payment3'] = payment3 832 server = ServerProxy('http://mgr:mgrpw@localhost/app', allow_none=True) 833 results = server.get_unpaid_payments(1) 834 self.assertEqual( 835 results,[ 836 {'display_item': None, 837 'p_id': '%s' % p_id_1, 838 'p_category': 'schoolfee', 839 'amount_auth': 12.12, 'p_session': 2012, 840 'p_state': 'unpaid', 841 'r_company': 'xyz'} 842 ]) 843 results = server.get_unpaid_payments(4) 844 self.assertEqual( 845 results,[ 846 {'display_item': None, 847 'p_id': '%s' % p_id_1, 848 'p_category': 'schoolfee', 849 'amount_auth': 12.12, 850 'p_session': 2012, 851 'p_state': 'unpaid', 852 'r_company': 'xyz'}, 853 {'display_item': None, 854 'p_id': '%s' % p_id_3, 855 'p_category': 'schoolfee', 856 'amount_auth': 12.12, 857 'p_session': 2012, 858 'p_state': 'unpaid', 859 'r_company': None} 860 ]) 861 results = server.get_unpaid_payments(4,'xyz') 862 self.assertEqual( 863 results,[ 864 {'display_item': None, 865 'p_id': '%s' % p_id_1, 866 'p_category': 'schoolfee', 867 'amount_auth': 12.12, 868 'p_session': 2012, 869 'p_state': 'unpaid', 870 'r_company': 'xyz'}, 871 ]) 872 873 REQUEST_XML = """\ 874 <?xml version="1.0"?> 875 <methodCall> 876 <methodName>get_unpaid_payments</methodName> 877 <params> 878 <param> 879 <value><string>1</string></value> 880 </param> 881 </params> 882 </methodCall>""" 883 RESPONSE_XML = """\ 884 <?xml version='1.0'?> 885 <methodResponse> 886 <params> 887 <param> 888 <value><array><data> 889 <value><struct> 890 <member> 891 <name>display_item</name> 892 <value><nil/></value></member> 893 <member> 894 <name>p_id</name> 895 <value><string>%s</string></value> 896 </member> 897 <member> 898 <name>r_company</name> 899 <value><string>xyz</string></value> 900 </member> 901 <member> 902 <name>p_category</name> 903 <value><string>schoolfee</string></value> 904 </member> 905 <member> 906 <name>amount_auth</name> 907 <value><double>12.12</double></value> 908 </member> 909 <member> 910 <name>p_session</name> 911 <value><int>2012</int></value> 912 </member> 913 <member> 914 <name>p_state</name> 915 <value><string>unpaid</string></value> 916 </member> 917 </struct></value> 918 </data></array></value> 919 </param> 920 </params> 921 </methodResponse> 922 """ % p_id_1 923 xmlout = self.XMLRPC_post(REQUEST_XML) 924 self.assertEqual(xmlout, RESPONSE_XML) 925 return
Note: See TracChangeset for help on using the changeset viewer.