<s> import datetime <EOL> import decimal <EOL> TENANT_ID_1 = '<STR_LIT>' <EOL> TENANT_ID_2 = '<STR_LIT>' <EOL> from stacktach import datetime_to_decimal as dt <EOL> IMAGE_UUID_1 = "<STR_LIT>" <EOL> INSTANCE_ID_1 = "<STR_LIT>" <EOL> INSTANCE_ID_2 = "<STR_LIT>" <EOL> INSTANCE_FLAVOR_ID_1 = "<STR_LIT:1>" <EOL> INSTANCE_FLAVOR_ID_2 = "<STR_LIT>" <EOL> INSTANCE_TYPE_ID_1 = "<STR_LIT>" <EOL> INSTANCE_TYPE_ID_2 = '<STR_LIT>' <EOL> one_hr = datetime . timedelta ( hours = <NUM_LIT:1> ) <EOL> DUMMY_TIME = datetime . datetime . utcnow ( ) <EOL> EARLIER_DUMMY_TIME = DUMMY_TIME - one_hr <EOL> LATER_DUMMY_TIME = DUMMY_TIME + one_hr <EOL> DECIMAL_DUMMY_TIME = dt . dt_to_decimal ( DUMMY_TIME ) <EOL> MESSAGE_ID_1 = "<STR_LIT>" <EOL> MESSAGE_ID_2 = "<STR_LIT>" <EOL> MESSAGE_ID_3 = "<STR_LIT>" <EOL> MESSAGE_ID_4 = "<STR_LIT>" <EOL> BANDWIDTH_PUBLIC_OUTBOUND = <NUM_LIT> <EOL> REQUEST_ID_1 = '<STR_LIT>' <EOL> REQUEST_ID_2 = '<STR_LIT>' <EOL> REQUEST_ID_3 = '<STR_LIT>' <EOL> RAX_OPTIONS_1 = '<STR_LIT:1>' <EOL> RAX_OPTIONS_2 = '<STR_LIT:2>' <EOL> OS_DISTRO_1 = "<STR_LIT>" <EOL> OS_DISTRO_2 = "<STR_LIT>" <EOL> OS_ARCH_1 = "<STR_LIT>" <EOL> OS_ARCH_2 = "<STR_LIT>" <EOL> OS_VERSION_1 = "<STR_LIT:1>" <EOL> OS_VERSION_2 = "<STR_LIT:2>" <EOL> LAUNCHED_AT_1 = decimal . Decimal ( "<STR_LIT>" ) <EOL> LAUNCHED_AT_2 = decimal . Decimal ( "<STR_LIT>" ) <EOL> DELETED_AT_1 = decimal . Decimal ( "<STR_LIT>" ) <EOL> DELETED_AT_2 = decimal . Decimal ( "<STR_LIT>" ) <EOL> SIZE_1 = <NUM_LIT> <EOL> SIZE_2 = <NUM_LIT> <EOL> CREATED_AT_1 = decimal . Decimal ( "<STR_LIT>" ) <EOL> CREATED_AT_2 = decimal . Decimal ( "<STR_LIT>" ) <EOL> IMAGE_OWNER_1 = "<STR_LIT>" <EOL> IMAGE_OWNER_2 = "<STR_LIT>" <EOL> TIMESTAMP_1 = "<STR_LIT>" <EOL> SETTLE_TIME = <NUM_LIT:5> <EOL> SETTLE_UNITS = "<STR_LIT>" <EOL> TICK_TIME = <NUM_LIT:10> <EOL> HOST = '<STR_LIT>' <EOL> PORT = '<STR_LIT>' <EOL> VIRTUAL_HOST = '<STR_LIT:/>' <EOL> USERID = '<STR_LIT>' <EOL> PASSWORD = '<STR_LIT:password>' <EOL> NOVA_VERIFIER_EVENT_TYPE = '<STR_LIT>' <EOL> GLANCE_VERIFIER_EVENT_TYPE = '<STR_LIT>' <EOL> FLAVOR_FIELD_NAME = '<STR_LIT>' <EOL> def decimal_utc ( t = datetime . datetime . utcnow ( ) ) : <EOL> return dt . dt_to_decimal ( t ) <EOL> def create_nova_notif ( request_id = None , instance = INSTANCE_ID_1 , type_id = '<STR_LIT:1>' , <EOL> launched = None , deleted = None , new_type_id = None , <EOL> message_id = MESSAGE_ID_1 , audit_period_beginning = None , <EOL> audit_period_ending = None , tenant_id = None , <EOL> rax_options = None , os_architecture = None , <EOL> os_version = None , os_distro = None ) : <EOL> notif = [ '<STR_LIT>' , { <EOL> '<STR_LIT>' : message_id , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : { } , <EOL> '<STR_LIT>' : instance , <EOL> '<STR_LIT>' : type_id , <EOL> } <EOL> } ] <EOL> notif [ <NUM_LIT:1> ] [ '<STR_LIT>' ] = request_id <EOL> notif [ <NUM_LIT:1> ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] = launched <EOL> notif [ <NUM_LIT:1> ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] = deleted <EOL> notif [ <NUM_LIT:1> ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] = new_type_id <EOL> notif [ <NUM_LIT:1> ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] = audit_period_beginning <EOL> notif [ <NUM_LIT:1> ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] = audit_period_ending <EOL> notif [ <NUM_LIT:1> ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] = tenant_id <EOL> notif [ <NUM_LIT:1> ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] = rax_options <EOL> notif [ <NUM_LIT:1> ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] = os_architecture <EOL> notif [ <NUM_LIT:1> ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] = os_distro <EOL> notif [ <NUM_LIT:1> ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] = os_version <EOL> return notif <EOL> def create_raw ( mox , when , event , instance = INSTANCE_ID_1 , <EOL> request_id = REQUEST_ID_1 , state = '<STR_LIT>' , old_task = '<STR_LIT>' , <EOL> host = '<STR_LIT>' , service = '<STR_LIT>' , json_str = '<STR_LIT>' ) : <EOL> raw = mox . CreateMockAnything ( ) <EOL> raw . host = host <EOL> raw . service = service <EOL> raw . instance = instance <EOL> raw . event = event <EOL> raw . when = when <EOL> raw . state = state <EOL> raw . old_task = old_task <EOL> raw . request_id = request_id <EOL> raw . json = json_str <EOL> return raw <EOL> def create_lifecycle ( mox , instance , last_state , last_task_state , last_raw ) : <EOL> lifecycle = mox . CreateMockAnything ( ) <EOL> lifecycle . instance = instance <EOL> lifecycle . last_state = last_state <EOL> lifecycle . last_task_state = last_task_state <EOL> lifecycle . last_raw = last_raw <EOL> return lifecycle <EOL> def create_timing ( mox , name , lifecycle , start_raw = None , start_when = None , <EOL> end_raw = None , end_when = None , diff = None ) : <EOL> timing = mox . CreateMockAnything ( ) <EOL> timing . name = name <EOL> timing . lifecycle = lifecycle <EOL> timing . start_raw = start_raw <EOL> timing . start_when = start_when <EOL> timing . end_raw = end_raw <EOL> timing . end_when = end_when <EOL> timing . diff = diff <EOL> return timing <EOL> def create_tracker ( mox , request_id , lifecycle , start , last_timing = None , <EOL> duration = str ( <NUM_LIT:0.0> ) ) : <EOL> tracker = mox . CreateMockAnything ( ) <EOL> tracker . request_id = request_id <EOL> tracker . lifecycle = lifecycle <EOL> tracker . start = start <EOL> tracker . last_timing = last_timing <EOL> tracker . duration = duration <EOL> return tracker <EOL> class FakeVerifierConfig ( object ) : <EOL> def __init__ ( self , host , port , virtual_host , userid , password , tick_time , <EOL> settle_time , settle_units , durable_queue , topics , notifs , <EOL> nova_event_type , glance_event_type , flavor_field_name ) : <EOL> self . host = lambda : host <EOL> self . port = lambda : port <EOL> self . virtual_host = lambda : virtual_host <EOL> self . userid = lambda : userid <EOL> self . password = lambda : password <EOL> self . pool_size = lambda : <NUM_LIT:5> <EOL> self . tick_time = lambda : tick_time <EOL> self . settle_time = lambda : settle_time <EOL> self . settle_units = lambda : settle_units <EOL> self . durable_queue = lambda : durable_queue <EOL> self . topics = lambda : topics <EOL> self . enable_notifications = lambda : notifs <EOL> self . validation_level = lambda : '<STR_LIT:all>' <EOL> self . nova_event_type = lambda : nova_event_type <EOL> self . glance_event_type = lambda : glance_event_type <EOL> self . flavor_field_name = lambda : flavor_field_name <EOL> def make_verifier_config ( notifs ) : <EOL> topics = { '<STR_LIT>' : [ '<STR_LIT>' ] } <EOL> config = FakeVerifierConfig ( HOST , PORT , VIRTUAL_HOST , USERID , <EOL> PASSWORD , TICK_TIME , SETTLE_TIME , <EOL> SETTLE_UNITS , True , topics , notifs , <EOL> NOVA_VERIFIER_EVENT_TYPE , <EOL> GLANCE_VERIFIER_EVENT_TYPE , <EOL> FLAVOR_FIELD_NAME ) <EOL> return config <EOL> def mock_datetime_utcnow ( mox , time ) : <EOL> mox . StubOutWithMock ( datetime , '<STR_LIT>' ) <EOL> datetime . datetime . utcnow ( ) . AndReturn ( time ) <EOL> mox . ReplayAll ( ) </s>
