<s> import os <EOL> import random <EOL> import mock <EOL> from werckercli import config <EOL> from werckercli . config import ENV_KEY_WERCKER_URL <EOL> from werckercli . tests import BasicClientCase <EOL> class GetValueTests ( BasicClientCase ) : <EOL> template_name = "<STR_LIT>" <EOL> repo_name = "<STR_LIT>" <EOL> def setUp ( self , * args , ** kwargs ) : <EOL> self . wercker_url = "<STR_LIT>" + str ( random . randint ( <NUM_LIT:1> , <NUM_LIT> ) ) <EOL> super ( GetValueTests , self ) . setUp ( * args , ** kwargs ) <EOL> class GetValueUrlTests ( GetValueTests ) : <EOL> def test_get_value_wercker_url ( self ) : <EOL> os . environ [ ENV_KEY_WERCKER_URL ] = self . wercker_url <EOL> result = config . get_value ( config . VALUE_WERCKER_URL ) <EOL> self . assertEqual ( result , self . wercker_url ) <EOL> del os . environ [ ENV_KEY_WERCKER_URL ] <EOL> result = config . get_value ( config . VALUE_WERCKER_URL ) <EOL> self . assertEqual ( result , config . DEFAULT_WERCKER_URL ) <EOL> def test_get_value_heroku_token ( self ) : <EOL> with mock . patch ( "<STR_LIT>" , mock . Mock ( ) ) as puts : <EOL> result = config . get_value ( config . VALUE_HEROKU_TOKEN ) <EOL> self . assertEqual ( puts . call_count , <NUM_LIT:1> ) <EOL> calls = puts . call_args_list <EOL> self . assertTrue ( '<STR_LIT>' in calls [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( result , '<STR_LIT>' ) <EOL> os . environ . pop ( '<STR_LIT>' ) <EOL> self . assertRaises ( IOError , config . get_value , config . VALUE_HEROKU_TOKEN ) <EOL> @ mock . patch ( "<STR_LIT>" , mock . Mock ( ) ) <EOL> def test_get_value_project_id ( self ) : <EOL> os . chdir ( self . get_git_path ( ) ) <EOL> result = config . get_value ( config . VALUE_PROJECT_ID ) <EOL> self . assertEqual ( result , None ) <EOL> class GetValueTokenTests ( GetValueTests ) : <EOL> wercker_url = config . DEFAULT_WERCKER_URL <EOL> def test_get_value_user_token ( self ) : <EOL> with mock . patch ( "<STR_LIT>" , mock . Mock ( ) ) : <EOL> result = config . get_value ( config . VALUE_USER_TOKEN ) <EOL> self . assertEqual ( result , "<STR_LIT>" ) <EOL> class SetValueTests ( BasicClientCase ) : <EOL> template_name = '<STR_LIT>' <EOL> repo_name = "<STR_LIT>" <EOL> def test_set_value_user_token ( self ) : <EOL> with mock . patch ( "<STR_LIT>" , mock . Mock ( ) ) : <EOL> config . set_value ( config . VALUE_USER_TOKEN , "<STR_LIT>" ) <EOL> self . assertEqual ( <EOL> config . get_value ( config . VALUE_USER_TOKEN ) , <EOL> '<STR_LIT>' <EOL> ) <EOL> def _test_set_value_project_id ( self ) : <EOL> self . assertRaises ( <EOL> NotImplementedError , <EOL> config . set_value , <EOL> config . VALUE_PROJECT_ID , <EOL> "<STR_LIT>" <EOL> ) </s>
