<s> from __future__ import print_function , unicode_literals <EOL> from gratipay . testing import Harness <EOL> from gratipay . models . participant import Participant <EOL> workflow = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> class Tests ( Harness ) : <EOL> def setUp ( self ) : <EOL> super ( Harness ) <EOL> self . make_participant ( '<STR_LIT>' , claimed_time = '<STR_LIT>' , last_paypal_result = '<STR_LIT>' ) <EOL> self . make_participant ( '<STR_LIT>' , claimed_time = '<STR_LIT>' , is_admin = True ) <EOL> def hit ( self , new_status , expecting_error = True , auth_as = '<STR_LIT>' ) : <EOL> method = self . client . PxST if expecting_error else self . client . POST <EOL> return method ( "<STR_LIT>" , { '<STR_LIT:to>' : new_status } , auth_as = auth_as ) <EOL> def test_admin_can_change_status ( self ) : <EOL> for status in workflow : <EOL> response = self . hit ( status , expecting_error = False ) <EOL> assert response . code == <NUM_LIT:200> <EOL> assert Participant . from_username ( '<STR_LIT>' ) . status_of_1_0_payout == status <EOL> def test_user_cant_change_status_except_for_applying ( self ) : <EOL> self . db . run ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> response = self . hit ( '<STR_LIT>' , auth_as = '<STR_LIT>' ) <EOL> assert response . code == <NUM_LIT> <EOL> assert Participant . from_username ( '<STR_LIT>' ) . status_of_1_0_payout == '<STR_LIT>' <EOL> response = self . hit ( '<STR_LIT>' , auth_as = '<STR_LIT>' , expecting_error = False ) <EOL> assert Participant . from_username ( '<STR_LIT>' ) . status_of_1_0_payout == '<STR_LIT>' <EOL> def test_user_must_have_a_payout_route ( self ) : <EOL> self . db . run ( "<STR_LIT>" ) <EOL> response = self . hit ( '<STR_LIT>' , auth_as = '<STR_LIT>' ) <EOL> assert response . code == <NUM_LIT> <EOL> assert Participant . from_username ( '<STR_LIT>' ) . status_of_1_0_payout == '<STR_LIT>' <EOL> def test_invalid_is_400 ( self ) : <EOL> response = self . hit ( '<STR_LIT>' ) <EOL> assert response . code == <NUM_LIT> <EOL> def test_can_update_status_via_trigger_on_participant_balance ( self ) : <EOL> self . db . run ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> alice = Participant . from_username ( '<STR_LIT>' ) <EOL> assert alice . balance == <NUM_LIT:10> <EOL> assert alice . status_of_1_0_payout == '<STR_LIT>' ; <EOL> self . db . run ( "<STR_LIT>" ) <EOL> alice = Participant . from_username ( '<STR_LIT>' ) <EOL> assert alice . balance == <NUM_LIT:0> <EOL> assert alice . status_of_1_0_payout == '<STR_LIT>' ; </s>
