Пример #1
0
    def test_case_parse_response(self):
        s = """<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetAllDataResponse xmlns="http://RCKServices.com/"><GetAllDataResult><SimData xmlns="http://RCKServices.com/CHWData.xsd"><PointData><Name>Differential Pressure 1</Name><Type>analog</Type><Value>17.67489</Value><Address>0</Address><Channel>0</Channel><ScaledZero>0</ScaledZero><ScaledFull>30</ScaledFull></PointData><PointData><Name>Differential Pressure 2</Name><Type>analog</Type><Value>19.72186</Value><Address>1</Address><Channel>1</Channel><ScaledZero>0</ScaledZero><ScaledFull>20</ScaledFull></PointData><PointData><Name>Differential Pressure 3</Name><Type>analog</Type><Value>27.32893</Value><Address>2</Address><Channel>2</Channel><ScaledZero>0</ScaledZero><ScaledFull>30</ScaledFull></PointData><PointData><Name>Differential Pressure 4</Name><Type>analog</Type><Value>11.3433</Value><Address>3</Address><Channel>3</Channel><ScaledZero>0</ScaledZero><ScaledFull>50</ScaledFull></PointData></SimData></GetAllDataResult></GetAllDataResponse></soap:Body></soap:Envelope>"""
        p = parse_response(s)
        x = {'Differential Pressure 3': {'Value': '27.32893', 
                                         'ScaledFull': '30', 
                                         'Name': 'Differential Pressure 3', 
                                         'Address': '2', 
                                         'ScaledZero': '0', 
                                         'Type': 'analog', 
                                         'Channel': '2'}, 
             'Differential Pressure 2': {'Value': '19.72186', 
                                         'ScaledFull': '20', 
                                         'Name': 'Differential Pressure 2', 
                                         'Address': '1', 
                                         'ScaledZero': '0', 
                                         'Type': 'analog', 
                                         'Channel': '1'}, 
             'Differential Pressure 1': {'Value': '17.67489',
                                         'ScaledFull': '30', 
                                         'Name': 'Differential Pressure 1', 
                                         'Address': '0', 
                                         'ScaledZero': '0', 
                                         'Type': 'analog', 
                                         'Channel': '0'}, 
             'Differential Pressure 4': {'Value': '11.3433', 
                                         'ScaledFull': '50', 
                                         'Name': 'Differential Pressure 4', 
                                         'Address': '3', 
                                         'ScaledZero': '0', 
                                         'Type': 'analog', 
                                         'Channel': '3'}}
        if x !=p:
            raise 'failed to parse xml response string'
Пример #2
0
def _integration_test_send_request_GetRequestedData():
    host = 'www.dev1.eraserver.net'
    post = '/RCKCONTROLS/RCKData.asmx'
    action_server = 'http://RCKServices.com/'
    action = 'GetRequestedData'
    list = []
    list.append([['Name', 'Differential Pressure 1'], ['Type', 'analog']])
    list.append([['Name', 'Differential Pressure 3'], ['Type', 'analog']])
    request = build_point_request(list)
    print request
    envelope_start = """<?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
        <""" + action + ' xmlns="' + action_server + '" >'
    envelope_end = """
        </""" + action + """>
      </soap:Body>
    </soap:Envelope>
    """
    r = suds.send_request(host, post, action_server + action,
                          envelope_start + request + envelope_end)
    print r
    rsp = parse_response(r)
    print rsp
    return rsp
Пример #3
0
    def test_case_parse_response(self):
        s = """<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetAllDataResponse xmlns="http://RCKServices.com/"><GetAllDataResult><SimData xmlns="http://RCKServices.com/CHWData.xsd"><PointData><Name>Differential Pressure 1</Name><Type>analog</Type><Value>17.67489</Value><Address>0</Address><Channel>0</Channel><ScaledZero>0</ScaledZero><ScaledFull>30</ScaledFull></PointData><PointData><Name>Differential Pressure 2</Name><Type>analog</Type><Value>19.72186</Value><Address>1</Address><Channel>1</Channel><ScaledZero>0</ScaledZero><ScaledFull>20</ScaledFull></PointData><PointData><Name>Differential Pressure 3</Name><Type>analog</Type><Value>27.32893</Value><Address>2</Address><Channel>2</Channel><ScaledZero>0</ScaledZero><ScaledFull>30</ScaledFull></PointData><PointData><Name>Differential Pressure 4</Name><Type>analog</Type><Value>11.3433</Value><Address>3</Address><Channel>3</Channel><ScaledZero>0</ScaledZero><ScaledFull>50</ScaledFull></PointData></SimData></GetAllDataResult></GetAllDataResponse></soap:Body></soap:Envelope>"""
        p = parse_response(s)
        x = {
            'Differential Pressure 3': {
                'Value': '27.32893',
                'ScaledFull': '30',
                'Name': 'Differential Pressure 3',
                'Address': '2',
                'ScaledZero': '0',
                'Type': 'analog',
                'Channel': '2'
            },
            'Differential Pressure 2': {
                'Value': '19.72186',
                'ScaledFull': '20',
                'Name': 'Differential Pressure 2',
                'Address': '1',
                'ScaledZero': '0',
                'Type': 'analog',
                'Channel': '1'
            },
            'Differential Pressure 1': {
                'Value': '17.67489',
                'ScaledFull': '30',
                'Name': 'Differential Pressure 1',
                'Address': '0',
                'ScaledZero': '0',
                'Type': 'analog',
                'Channel': '0'
            },
            'Differential Pressure 4': {
                'Value': '11.3433',
                'ScaledFull': '50',
                'Name': 'Differential Pressure 4',
                'Address': '3',
                'ScaledZero': '0',
                'Type': 'analog',
                'Channel': '3'
            }
        }
        if x != p:
            raise 'failed to parse xml response string'
Пример #4
0
def _integration_test_send_request_GetAllData():
    host = 'www.dev1.eraserver.net'
    post = '/RCKCONTROLS/RCKData.asmx'
    action_server = 'http://RCKServices.com/'
    action = 'GetAllData'
    request = ''
    envelope_start = """<?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
        <""" + action + ' xmlns="' + action_server + '" />'
    envelope_end = """
      </soap:Body>
    </soap:Envelope>
    """
    r = suds.send_request(host, post, action_server + action, envelope_start + request + envelope_end)
    print r
    rsp = parse_response(r)
    print rsp
    return rsp
Пример #5
0
def _integration_test_send_request_GetAllData():
    host = 'www.dev1.eraserver.net'
    post = '/RCKCONTROLS/RCKData.asmx'
    action_server = 'http://RCKServices.com/'
    action = 'GetAllData'
    request = ''
    envelope_start = """<?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
        <""" + action + ' xmlns="' + action_server + '" />'
    envelope_end = """
      </soap:Body>
    </soap:Envelope>
    """
    r = suds.send_request(host, post, action_server + action,
                          envelope_start + request + envelope_end)
    print r
    rsp = parse_response(r)
    print rsp
    return rsp
Пример #6
0
def _integration_test_send_request_GetRequestedData():
    host = 'www.dev1.eraserver.net'
    post = '/RCKCONTROLS/RCKData.asmx'
    action_server = 'http://RCKServices.com/'
    action = 'GetRequestedData'
    list = []
    list.append([['Name','Differential Pressure 1'], ['Type','analog']])
    list.append([['Name','Differential Pressure 3'], ['Type','analog']])
    request = build_point_request(list)
    print request
    envelope_start = """<?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
        <""" + action + ' xmlns="' + action_server + '" >'
    envelope_end = """
        </""" + action + """>
      </soap:Body>
    </soap:Envelope>
    """
    r = suds.send_request(host, post, action_server + action, envelope_start + request + envelope_end)
    print r
    rsp = parse_response(r)
    print rsp
    return rsp