<s> import datetime <EOL> import uuid <EOL> from nova import objects <EOL> from nova . objects import fields <EOL> import six <EOL> def fake_db_instance ( ** updates ) : <EOL> flavorinfo = None <EOL> db_instance = { <EOL> '<STR_LIT:id>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : str ( uuid . uuid4 ( ) ) , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:host>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : datetime . datetime ( <NUM_LIT> , <NUM_LIT:11> , <NUM_LIT:5> ) , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : { } , <EOL> '<STR_LIT>' : { } , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : { '<STR_LIT>' : None , <EOL> '<STR_LIT>' : flavorinfo , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : None , <EOL> } , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : [ ] <EOL> } <EOL> for name , field in six . iteritems ( objects . Instance . fields ) : <EOL> if name in db_instance : <EOL> continue <EOL> if field . nullable : <EOL> db_instance [ name ] = None <EOL> elif field . default != fields . UnspecifiedDefault : <EOL> db_instance [ name ] = field . default <EOL> elif name in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> pass <EOL> else : <EOL> raise Exception ( '<STR_LIT>' % name ) <EOL> if updates : <EOL> db_instance . update ( updates ) <EOL> return db_instance <EOL> def fake_instance_obj ( context , ** updates ) : <EOL> expected_attrs = updates . pop ( '<STR_LIT>' , None ) <EOL> return objects . Instance . _from_db_object ( context , <EOL> objects . Instance ( ) , fake_db_instance ( ** updates ) , <EOL> expected_attrs = expected_attrs ) </s>
