<s> import xml . sax <EOL> import unittest <EOL> from boto import handler <EOL> from boto . emr import emrobject <EOL> from boto . resultset import ResultSet <EOL> JOB_FLOW_EXAMPLE = """<STR_LIT>""" <EOL> JOB_FLOW_COMPLETED = """<STR_LIT>""" <EOL> class TestEMRResponses ( unittest . TestCase ) : <EOL> def _parse_xml ( self , body , markers ) : <EOL> rs = ResultSet ( markers ) <EOL> h = handler . XmlHandler ( rs , None ) <EOL> xml . sax . parseString ( body , h ) <EOL> return rs <EOL> def _assert_fields ( self , response , ** fields ) : <EOL> for field , expected in fields . items ( ) : <EOL> actual = getattr ( response , field ) <EOL> self . assertEquals ( expected , actual , <EOL> "<STR_LIT>" % ( field , expected , actual ) ) <EOL> def test_JobFlows_example ( self ) : <EOL> [ jobflow ] = self . _parse_xml ( JOB_FLOW_EXAMPLE , <EOL> [ ( '<STR_LIT>' , emrobject . JobFlow ) ] ) <EOL> self . _assert_fields ( jobflow , <EOL> creationdatetime = '<STR_LIT>' , <EOL> startdatetime = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> instancecount = '<STR_LIT:4>' , <EOL> jobflowid = '<STR_LIT>' , <EOL> loguri = '<STR_LIT>' , <EOL> name = '<STR_LIT>' , <EOL> availabilityzone = '<STR_LIT>' , <EOL> slaveinstancetype = '<STR_LIT>' , <EOL> masterinstancetype = '<STR_LIT>' , <EOL> ec2keyname = '<STR_LIT>' , <EOL> keepjobflowalivewhennosteps = '<STR_LIT:true>' ) <EOL> def test_JobFlows_completed ( self ) : <EOL> [ jobflow ] = self . _parse_xml ( JOB_FLOW_COMPLETED , <EOL> [ ( '<STR_LIT>' , emrobject . JobFlow ) ] ) <EOL> self . _assert_fields ( jobflow , <EOL> creationdatetime = '<STR_LIT>' , <EOL> startdatetime = '<STR_LIT>' , <EOL> enddatetime = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> instancecount = '<STR_LIT>' , <EOL> jobflowid = '<STR_LIT>' , <EOL> loguri = '<STR_LIT>' , <EOL> name = '<STR_LIT>' , <EOL> availabilityzone = '<STR_LIT>' , <EOL> slaveinstancetype = '<STR_LIT>' , <EOL> masterinstancetype = '<STR_LIT>' , <EOL> ec2keyname = '<STR_LIT>' , <EOL> keepjobflowalivewhennosteps = '<STR_LIT:false>' ) <EOL> self . assertEquals ( <NUM_LIT:6> , len ( jobflow . steps ) ) <EOL> self . assertEquals ( <NUM_LIT:2> , len ( jobflow . instancegroups ) ) </s>
