<s> import time <EOL> import mock <EOL> from behave import then <EOL> from behave import when <EOL> import paasta_tools <EOL> from paasta_tools . mesos_tools import get_local_slave_state <EOL> APP_ID = '<STR_LIT>' <EOL> @ when ( u'<STR_LIT>' ) <EOL> def create_trivial_marathon_app ( context ) : <EOL> app_config = { <EOL> '<STR_LIT:id>' : APP_ID , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> } <EOL> with mock . patch ( '<STR_LIT>' ) : <EOL> paasta_tools . bounce_lib . create_marathon_app ( app_config [ '<STR_LIT:id>' ] , app_config , context . marathon_client ) <EOL> @ then ( u'<STR_LIT>' ) <EOL> def list_marathon_apps_has_trivial_app ( context ) : <EOL> actual = paasta_tools . marathon_tools . list_all_marathon_app_ids ( context . marathon_client ) <EOL> assert APP_ID in actual <EOL> assert context . marathon_client . get_app ( '<STR_LIT>' % APP_ID ) <EOL> @ then ( u'<STR_LIT>' ) <EOL> def marathon_services_running_here_works ( context ) : <EOL> with mock . patch ( '<STR_LIT>' , return_value = '<STR_LIT>' ) : <EOL> discovered = paasta_tools . marathon_tools . marathon_services_running_here ( ) <EOL> assert len ( discovered ) == <NUM_LIT:1> , ( repr ( discovered ) , get_local_slave_state ( ) ) <EOL> assert discovered == [ ( u'<STR_LIT>' , u'<STR_LIT>' , mock . ANY ) ] , repr ( discovered ) <EOL> @ when ( u'<STR_LIT>' ) <EOL> def when_the_task_has_started ( context ) : <EOL> for _ in xrange ( <NUM_LIT> ) : <EOL> app = context . marathon_client . get_app ( APP_ID ) <EOL> happy_count = app . tasks_running <EOL> if happy_count >= <NUM_LIT:1> : <EOL> return <EOL> time . sleep ( <NUM_LIT:0.5> ) <EOL> raise Exception ( "<STR_LIT>" ) </s>
