<s> import os <EOL> import time <EOL> import json <EOL> from datetime import datetime , timedelta <EOL> from urllib import urlencode <EOL> from world import world <EOL> from bigml . api import HTTP_CREATED , HTTP_ACCEPTED <EOL> from bigml . api import FINISHED <EOL> from bigml . api import FAULTY <EOL> from bigml . api import UPLOADING <EOL> from bigml . api import get_status <EOL> from read_project_steps import i_get_the_project <EOL> def i_create_project ( step , name ) : <EOL> resource = world . api . create_project ( { "<STR_LIT:name>" : name } ) <EOL> world . status = resource [ '<STR_LIT:code>' ] <EOL> world . location = resource [ '<STR_LIT:location>' ] <EOL> world . project = resource [ '<STR_LIT:object>' ] <EOL> world . projects . append ( resource [ '<STR_LIT>' ] ) <EOL> def wait_until_project_status_code_is ( step , code1 , code2 , secs ) : <EOL> start = datetime . utcnow ( ) <EOL> i_get_the_project ( step , world . project [ '<STR_LIT>' ] ) <EOL> status = get_status ( world . project ) <EOL> while ( status [ '<STR_LIT:code>' ] != int ( code1 ) and <EOL> status [ '<STR_LIT:code>' ] != int ( code2 ) ) : <EOL> time . sleep ( <NUM_LIT:3> ) <EOL> assert datetime . utcnow ( ) - start < timedelta ( seconds = int ( secs ) ) <EOL> i_get_the_project ( step , world . project [ '<STR_LIT>' ] ) <EOL> status = get_status ( world . project ) <EOL> assert status [ '<STR_LIT:code>' ] == int ( code1 ) <EOL> def the_project_is_finished ( step , secs ) : <EOL> wait_until_project_status_code_is ( step , FINISHED , FAULTY , secs ) <EOL> def i_update_project_name_with ( step , name = "<STR_LIT>" ) : <EOL> resource = world . api . update_project ( world . project . get ( '<STR_LIT>' ) , <EOL> { "<STR_LIT:name>" : name } ) <EOL> world . status = resource [ '<STR_LIT:code>' ] <EOL> assert world . status == HTTP_ACCEPTED <EOL> world . project = resource [ '<STR_LIT:object>' ] <EOL> def i_check_project_name ( step , name = "<STR_LIT>" ) : <EOL> updated_name = world . project . get ( "<STR_LIT:name>" , "<STR_LIT>" ) <EOL> if updated_name == name : <EOL> assert True <EOL> else : <EOL> assert False , "<STR_LIT>" % ( updated_name , <EOL> name ) </s>
