<s> """<STR_LIT>""" <EOL> from functools import partial <EOL> import json <EOL> import httpretty <EOL> import mock <EOL> from orcoursetrion . actions import ( <EOL> create_export_repo , <EOL> rerun_studio , <EOL> release_studio , <EOL> create_xml_repo , <EOL> rerun_xml , <EOL> release_xml , <EOL> put_team , <EOL> ) <EOL> from orcoursetrion . actions . github import ( <EOL> COMMITTER , <EOL> GITIGNORE_CONTENTS , <EOL> GITIGNORE_MESSAGE , <EOL> GITIGNORE_PATH <EOL> ) <EOL> from orcoursetrion . tests . base import TestGithubBase <EOL> class TestActions ( TestGithubBase ) : <EOL> """<STR_LIT>""" <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ httpretty . activate <EOL> def test_create_export_repo_success ( self , config ) : <EOL> """<STR_LIT>""" <EOL> config . ORC_GH_OAUTH2_TOKEN = self . OAUTH2_TOKEN <EOL> config . ORC_GH_API_URL = self . URL [ : - <NUM_LIT:1> ] <EOL> config . ORC_COURSE_PREFIX = self . TEST_PREFIX <EOL> config . ORC_STUDIO_ORG = self . ORG <EOL> config . ORC_STUDIO_DEPLOY_TEAM = self . TEST_TEAM <EOL> self . register_repo_check ( self . callback_repo_check ) <EOL> self . register_repo_create ( self . callback_repo_create ) <EOL> self . register_team_list ( <EOL> partial ( self . callback_team_list , more = True ) <EOL> ) <EOL> self . register_team_repo_add ( self . callback_team_repo ) <EOL> with mock . patch ( <EOL> '<STR_LIT>' <EOL> ) as mock_add_file : <EOL> create_export_repo ( <EOL> self . TEST_COURSE , <EOL> self . TEST_TERM , <EOL> description = self . TEST_DESCRIPTION <EOL> ) <EOL> mock_add_file . assert_called_with ( <EOL> org = config . ORC_STUDIO_ORG , <EOL> repo = '<STR_LIT>' . format ( <EOL> prefix = self . TEST_PREFIX , <EOL> course = self . TEST_COURSE . replace ( '<STR_LIT:.>' , '<STR_LIT>' ) , <EOL> term = self . TEST_TERM <EOL> ) , <EOL> committer = COMMITTER , <EOL> message = GITIGNORE_MESSAGE , <EOL> path = GITIGNORE_PATH , <EOL> contents = GITIGNORE_CONTENTS <EOL> ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ httpretty . activate <EOL> def test_rerun_studio_success ( self , config ) : <EOL> """<STR_LIT>""" <EOL> config . ORC_GH_OAUTH2_TOKEN = self . OAUTH2_TOKEN <EOL> config . ORC_GH_API_URL = self . URL <EOL> config . ORC_COURSE_PREFIX = self . TEST_PREFIX <EOL> config . ORC_STUDIO_ORG = self . ORG <EOL> config . ORC_STUDIO_DEPLOY_TEAM = self . TEST_TEAM <EOL> self . register_repo_check ( <EOL> partial ( self . callback_repo_check , status_code = <NUM_LIT:200> ) <EOL> ) <EOL> self . register_repo_create ( self . callback_repo_create ) <EOL> self . register_team_list ( <EOL> partial ( self . callback_team_list , more = True ) <EOL> ) <EOL> self . register_team_repo_add ( self . callback_team_repo ) <EOL> self . register_hook_list ( ) <EOL> self . register_hook_delete ( ) <EOL> with mock . patch ( <EOL> '<STR_LIT>' <EOL> ) as mock_add_file : <EOL> rerun_studio ( <EOL> self . TEST_COURSE , <EOL> self . TEST_TERM , <EOL> self . TEST_NEW_TERM , <EOL> description = self . TEST_DESCRIPTION <EOL> ) <EOL> mock_add_file . assert_called_with ( <EOL> org = config . ORC_STUDIO_ORG , <EOL> repo = '<STR_LIT>' . format ( <EOL> prefix = self . TEST_PREFIX , <EOL> course = self . TEST_COURSE . replace ( '<STR_LIT:.>' , '<STR_LIT>' ) , <EOL> term = self . TEST_NEW_TERM <EOL> ) , <EOL> committer = COMMITTER , <EOL> message = GITIGNORE_MESSAGE , <EOL> path = GITIGNORE_PATH , <EOL> contents = GITIGNORE_CONTENTS <EOL> ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ httpretty . activate <EOL> def test_release_studio_success ( self , config ) : <EOL> """<STR_LIT>""" <EOL> config . ORC_GH_OAUTH2_TOKEN = self . OAUTH2_TOKEN <EOL> config . ORC_GH_API_URL = self . URL <EOL> config . ORC_COURSE_PREFIX = self . TEST_PREFIX <EOL> config . ORC_STUDIO_ORG = self . ORG <EOL> config . ORC_PRODUCTION_GITRELOAD = self . TEST_PRODUCTION_GR <EOL> self . register_hook_create ( json . dumps ( { '<STR_LIT:id>' : <NUM_LIT:2> } ) , status = <NUM_LIT> ) <EOL> self . register_team_repo_add ( self . callback_team_repo ) <EOL> release_studio ( <EOL> self . TEST_COURSE , <EOL> self . TEST_TERM , <EOL> ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ httpretty . activate <EOL> def test_create_xml_repo_success_old_team ( self , config ) : <EOL> """<STR_LIT>""" <EOL> config . ORC_GH_OAUTH2_TOKEN = self . OAUTH2_TOKEN <EOL> config . ORC_GH_API_URL = self . URL <EOL> config . ORC_COURSE_PREFIX = self . TEST_PREFIX <EOL> config . ORC_XML_ORG = self . ORG <EOL> config . ORC_XML_DEPLOY_TEAM = self . TEST_TEAM <EOL> config . ORC_STAGING_GITRELOAD = self . TEST_STAGING_GR <EOL> self . register_repo_check ( self . callback_repo_check ) <EOL> self . register_repo_create ( self . callback_repo_create ) <EOL> self . register_team_list ( <EOL> partial ( self . callback_team_list , more = True ) <EOL> ) <EOL> self . register_team_repo_add ( self . callback_team_repo ) <EOL> self . register_hook_create ( <EOL> body = json . dumps ( { '<STR_LIT:id>' : <NUM_LIT:1> } ) , <EOL> status = <NUM_LIT> <EOL> ) <EOL> create_xml_repo ( <EOL> course = self . TEST_COURSE , <EOL> term = self . TEST_TERM , <EOL> team = self . TEST_TEAM , <EOL> description = self . TEST_DESCRIPTION , <EOL> ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ httpretty . activate <EOL> def test_create_xml_repo_success_new_team ( self , config ) : <EOL> """<STR_LIT>""" <EOL> config . ORC_GH_OAUTH2_TOKEN = self . OAUTH2_TOKEN <EOL> config . ORC_GH_API_URL = self . URL <EOL> config . ORC_COURSE_PREFIX = self . TEST_PREFIX <EOL> config . ORC_XML_ORG = self . ORG <EOL> config . ORC_XML_DEPLOY_TEAM = self . TEST_TEAM <EOL> config . ORC_STAGING_GITRELOAD = self . TEST_STAGING_GR <EOL> self . register_repo_check ( self . callback_repo_check ) <EOL> self . register_repo_create ( self . callback_repo_create ) <EOL> self . register_team_list ( <EOL> partial ( self . callback_team_list , more = True ) <EOL> ) <EOL> self . register_team_repo_add ( self . callback_team_repo ) <EOL> self . register_hook_create ( <EOL> body = json . dumps ( { '<STR_LIT:id>' : <NUM_LIT:1> } ) , <EOL> status = <NUM_LIT> <EOL> ) <EOL> member_changes = [ ] <EOL> member_list = [ '<STR_LIT>' ] <EOL> self . register_team_members ( <EOL> partial ( self . callback_team_members , members = [ ] ) <EOL> ) <EOL> self . register_team_create ( <EOL> partial ( self . callback_team_create , read_only = False ) <EOL> ) <EOL> self . register_team_membership ( <EOL> partial ( self . callback_team_membership , action_list = member_changes ) <EOL> ) <EOL> create_xml_repo ( <EOL> course = self . TEST_COURSE , <EOL> term = self . TEST_TERM , <EOL> team = '<STR_LIT>' , <EOL> members = member_list , <EOL> description = self . TEST_DESCRIPTION <EOL> ) <EOL> self . assertItemsEqual ( <EOL> [ ( unicode ( x ) , True ) for x in member_list ] , <EOL> member_changes <EOL> ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ httpretty . activate <EOL> def test_create_xml_repo_success_no_team ( self , config ) : <EOL> """<STR_LIT>""" <EOL> config . ORC_GH_OAUTH2_TOKEN = self . OAUTH2_TOKEN <EOL> config . ORC_GH_API_URL = self . URL <EOL> config . ORC_COURSE_PREFIX = self . TEST_PREFIX <EOL> config . ORC_XML_ORG = self . ORG <EOL> config . ORC_XML_DEPLOY_TEAM = self . TEST_TEAM <EOL> config . ORC_STAGING_GITRELOAD = self . TEST_STAGING_GR <EOL> self . register_repo_check ( self . callback_repo_check ) <EOL> self . register_repo_create ( self . callback_repo_create ) <EOL> self . register_team_list ( <EOL> partial ( self . callback_team_list , more = True ) <EOL> ) <EOL> self . register_team_repo_add ( self . callback_team_repo ) <EOL> self . register_hook_create ( <EOL> body = json . dumps ( { '<STR_LIT:id>' : <NUM_LIT:1> } ) , <EOL> status = <NUM_LIT> <EOL> ) <EOL> member_changes = [ ] <EOL> member_list = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . register_team_members ( <EOL> partial ( self . callback_team_members , members = [ ] ) <EOL> ) <EOL> self . register_team_create ( <EOL> partial ( self . callback_team_create , read_only = False ) <EOL> ) <EOL> self . register_team_membership ( <EOL> partial ( self . callback_team_membership , action_list = member_changes ) <EOL> ) <EOL> create_xml_repo ( <EOL> course = self . TEST_COURSE , <EOL> term = self . TEST_TERM , <EOL> members = member_list , <EOL> description = self . TEST_DESCRIPTION <EOL> ) <EOL> self . assertItemsEqual ( <EOL> [ ( unicode ( x ) , True ) for x in member_list ] , <EOL> member_changes <EOL> ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ httpretty . activate <EOL> def test_rerun_xml_success ( self , config ) : <EOL> """<STR_LIT>""" <EOL> config . ORC_GH_OAUTH2_TOKEN = self . OAUTH2_TOKEN <EOL> config . ORC_GH_API_URL = self . URL <EOL> config . ORC_COURSE_PREFIX = self . TEST_PREFIX <EOL> config . ORC_XML_ORG = self . ORG <EOL> self . register_repo_check ( <EOL> partial ( self . callback_repo_check , status_code = <NUM_LIT:200> ) <EOL> ) <EOL> self . register_hook_list ( ) <EOL> self . register_hook_delete ( ) <EOL> hooks_deleted = rerun_xml ( self . TEST_COURSE , self . TEST_TERM ) <EOL> self . assertEqual ( <NUM_LIT:1> , hooks_deleted ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ httpretty . activate <EOL> def test_release_xml_success ( self , config ) : <EOL> """<STR_LIT>""" <EOL> config . ORC_GH_OAUTH2_TOKEN = self . OAUTH2_TOKEN <EOL> config . ORC_GH_API_URL = self . URL <EOL> config . ORC_COURSE_PREFIX = self . TEST_PREFIX <EOL> config . ORC_XML_ORG = self . ORG <EOL> config . ORC_PRODUCTION_GITRELOAD = self . TEST_PRODUCTION_GR <EOL> self . register_hook_create ( json . dumps ( { '<STR_LIT:id>' : <NUM_LIT:2> } ) , status = <NUM_LIT> ) <EOL> self . register_team_repo_add ( self . callback_team_repo ) <EOL> release_xml ( <EOL> self . TEST_COURSE , <EOL> self . TEST_TERM , <EOL> ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ httpretty . activate <EOL> def test_put_team_success ( self , config ) : <EOL> """<STR_LIT>""" <EOL> config . ORC_GH_OAUTH2_TOKEN = self . OAUTH2_TOKEN <EOL> config . ORC_GH_API_URL = self . URL <EOL> config . ORC_COURSE_PREFIX = self . TEST_PREFIX <EOL> config . ORC_XML_ORG = self . ORG <EOL> config . ORC_XML_DEPLOY_TEAM = self . TEST_TEAM <EOL> config . ORC_STAGING_GITRELOAD = self . TEST_STAGING_GR <EOL> member_changes = [ ] <EOL> self . register_team_list ( <EOL> partial ( self . callback_team_list , more = True ) <EOL> ) <EOL> self . register_team_members ( <EOL> partial ( self . callback_team_members , members = [ ] ) <EOL> ) <EOL> self . register_team_create ( <EOL> partial ( self . callback_team_create , read_only = False ) <EOL> ) <EOL> self . register_team_membership ( <EOL> partial ( self . callback_team_membership , action_list = member_changes ) <EOL> ) <EOL> put_team ( <EOL> org = self . ORG , <EOL> team = self . TEST_TEAM , <EOL> read_only = True , <EOL> members = self . TEST_TEAM_MEMBERS <EOL> ) <EOL> self . assertItemsEqual ( <EOL> [ ( unicode ( x ) , True ) for x in self . TEST_TEAM_MEMBERS ] , <EOL> member_changes <EOL> ) </s>
