'test of fields stanza'

def testFields(self):

    msg = self.Message()
    msg['from'] = 'device@clayster.com'
    msg['to'] = 'master@clayster.com/amr'
    msg['fields']['seqnr'] = '1'
    node = msg['fields'].add_node('Device02')
    ts = node.add_timestamp('2013-03-07T16:24:30')
    data = ts.add_data(typename='numeric', name='Temperature', value='-12.42', unit='K')
    data['momentary'] = 'true'
    data['automaticReadout'] = 'true'
    self.check(msg, "\n                                                <message    from='device@clayster.com'\n                                                                                to='master@clayster.com/amr'>\n                                                                <fields    xmlns='urn:xmpp:iot:sensordata'    seqnr='1'>\n                                                                                <node    nodeId='Device02'>\n                                                                                                <timestamp    value='2013-03-07T16:24:30'>\n                                                                                                                <numeric    name='Temperature'    momentary='true'    automaticReadout='true'    value='-12.42'    unit='K'/>\n                                                                                                </timestamp>\n                                                                                </node>\n                                                                </fields>\n                                                </message>\n                                                                                            ")
    node = msg['fields'].add_node('EmptyDevice')
    node = msg['fields'].add_node('Device04')
    ts = node.add_timestamp('EmptyTimestamp')
    self.check(msg, "\n                                                <message    from='device@clayster.com'\n                                                                                to='master@clayster.com/amr'>\n                                                                <fields    xmlns='urn:xmpp:iot:sensordata'    seqnr='1'>\n                                                                                <node    nodeId='Device02'>\n                                                                                                <timestamp    value='2013-03-07T16:24:30'>\n                                                                                                                <numeric    name='Temperature'    momentary='true'    automaticReadout='true'    value='-12.42'    unit='K'/>\n                                                                                                </timestamp>\n                                                                                </node>\n                                                                                <node    nodeId='EmptyDevice'/>\n                                                                                <node    nodeId='Device04'>\n                                                                                                <timestamp    value='EmptyTimestamp'/>\n                                                                                </node>\n                                                                </fields>\n                                                </message>\n                                                                                            ")
    node = msg['fields'].add_node('Device77')
    ts = node.add_timestamp('2013-05-03T12:00:01')
    data = ts.add_data(typename='numeric', name='Temperature', value='-12.42', unit='K')
    data['historicalDay'] = 'true'
    data = ts.add_data(typename='numeric', name='Speed', value='312.42', unit='km/h')
    data['historicalWeek'] = 'false'
    data = ts.add_data(typename='string', name='Temperature    name', value='Bottom    oil')
    data['historicalMonth'] = 'true'
    data = ts.add_data(typename='string', name='Speed    name', value='Top    speed')
    data['historicalQuarter'] = 'false'
    data = ts.add_data(typename='dateTime', name='T1', value='1979-01-01T00:00:00')
    data['historicalYear'] = 'true'
    data = ts.add_data(typename='dateTime', name='T2', value='2000-01-01T01:02:03')
    data['historicalOther'] = 'false'
    data = ts.add_data(typename='timeSpan', name='TS1', value='P5Y')
    data['missing'] = 'true'
    data = ts.add_data(typename='timeSpan', name='TS2', value='PT2M1S')
    data['manualEstimate'] = 'false'
    data = ts.add_data(typename='enum', name='top    color', value='red', dataType='string')
    data['invoiced'] = 'true'
    data = ts.add_data(typename='enum', name='bottom    color', value='black', dataType='string')
    data['powerFailure'] = 'false'
    data = ts.add_data(typename='boolean', name='Temperature    real', value='false')
    data['historicalDay'] = 'true'
    data = ts.add_data(typename='boolean', name='Speed    real', value='true')
    data['historicalWeek'] = 'false'
    self.check(msg, "\n                                                <message    from='device@clayster.com'\n                                                                                to='master@clayster.com/amr'>\n                                                                <fields    xmlns='urn:xmpp:iot:sensordata'    seqnr='1'>\n                                                                                <node    nodeId='Device02'>\n                                                                                                <timestamp    value='2013-03-07T16:24:30'>\n                                                                                                                <numeric    name='Temperature'    momentary='true'    automaticReadout='true'    value='-12.42'    unit='K'/>\n                                                                                                </timestamp>\n                                                                                </node>\n                                                                                <node    nodeId='EmptyDevice'/>\n                                                                                <node    nodeId='Device04'>\n                                                                                                <timestamp    value='EmptyTimestamp'/>\n                                                                                </node>\n                                                                                <node    nodeId='Device77'>\n                                                                                                <timestamp    value='2013-05-03T12:00:01'>\n                                                                                                                <numeric    name='Temperature'    historicalDay='true'    value='-12.42'    unit='K'/>\n                                                                                                                <numeric    name='Speed'    historicalWeek='false'    value='312.42'    unit='km/h'/>\n                                                                                                                <string    name='Temperature    name'    historicalMonth='true'    value='Bottom    oil'/>\n                                                                                                                <string    name='Speed    name'    historicalQuarter='false'    value='Top    speed'/>\n                                                                                                                <dateTime    name='T1'    historicalYear='true'    value='1979-01-01T00:00:00'/>\n                                                                                                                <dateTime    name='T2'    historicalOther='false'    value='2000-01-01T01:02:03'/>\n                                                                                                                <timeSpan    name='TS1'    missing='true'    value='P5Y'/>\n                                                                                                                <timeSpan    name='TS2'    manualEstimate='false'    value='PT2M1S'/>\n                                                                                                                <enum    name='top    color'    invoiced='true'    value='red'    dataType='string'/>\n                                                                                                                <enum    name='bottom    color'    powerFailure='false'    value='black'    dataType='string'/>\n                                                                                                                <boolean    name='Temperature    real'    historicalDay='true'    value='false'/>\n                                                                                                                <boolean    name='Speed    real'    historicalWeek='false'    value='true'/>\n                                                                                                </timestamp>\n                                                                                </node>\n                                                                </fields>\n                                                </message>\n                                                                                            ")
