<s> from django . contrib . auth import get_user_model <EOL> from django . core . urlresolvers import reverse <EOL> from django . test import TestCase , override_settings <EOL> from mock import patch <EOL> from buildservice . errors import MissingToken , InvalidStatus <EOL> from buildservice . models import Build , Repository <EOL> from buildservice . utils . testing import create_user_token <EOL> @ override_settings ( BUILDSERVICE_BASE_URL = '<STR_LIT>' ) <EOL> class BuildTestCase ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . user = get_user_model ( ) . objects . create_user ( '<STR_LIT:user>' , password = '<STR_LIT>' ) <EOL> self . repo = Repository . objects . create ( name = '<STR_LIT>' ) <EOL> self . repo . users . add ( self . user ) <EOL> self . build = Build . objects . create ( <EOL> repository = self . repo , <EOL> pusher_name = '<STR_LIT>' , <EOL> branch = '<STR_LIT>' , <EOL> sha = '<STR_LIT>' , <EOL> number = <NUM_LIT> <EOL> ) <EOL> def test_pusher_profile_url ( self ) : <EOL> self . assertEqual ( self . build . pusher_profile_url , '<STR_LIT>' ) <EOL> def test_url ( self ) : <EOL> build_detail = reverse ( '<STR_LIT>' , args = [ self . repo . name , self . build . number ] ) <EOL> self . assertEqual ( self . build . url , '<STR_LIT>' % build_detail ) <EOL> def test_is_success_yes ( self ) : <EOL> self . build . status = '<STR_LIT:success>' <EOL> self . assertTrue ( self . build . is_success ) <EOL> def test_is_success_no ( self ) : <EOL> self . assertFalse ( self . build . is_success ) <EOL> def test_is_pending_yes ( self ) : <EOL> self . assertTrue ( self . build . is_pending ) <EOL> def test_is_pending_no ( self ) : <EOL> self . build . status = '<STR_LIT>' <EOL> self . assertFalse ( self . build . is_pending ) <EOL> def test_short_sha ( self ) : <EOL> self . assertEqual ( self . build . short_sha , '<STR_LIT>' ) <EOL> def test_update_status_no_token ( self ) : <EOL> self . assertRaises ( MissingToken , self . build . update_status , '<STR_LIT>' ) <EOL> def test_update_status_bad_status ( self ) : <EOL> create_user_token ( self . user , self . repo ) <EOL> self . assertRaises ( InvalidStatus , self . build . update_status , '<STR_LIT>' ) <EOL> self . build . refresh_from_db ( ) <EOL> self . assertEqual ( self . build . status , '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_update_status_ok ( self , create_status ) : <EOL> token = create_user_token ( self . user , self . repo ) <EOL> self . build . update_status ( '<STR_LIT:success>' ) <EOL> self . build . refresh_from_db ( ) <EOL> self . assertEqual ( self . build . status , '<STR_LIT:success>' ) <EOL> create_status . assert_called_with ( <EOL> token . value , '<STR_LIT>' , self . build . sha , <EOL> state = '<STR_LIT:success>' , target_url = self . build . url <EOL> ) </s>
