<s> import qisys . command <EOL> import qisys . sh <EOL> import qisrc . git <EOL> from qisrc . test . conftest import TestGitWorkTree , TestGit <EOL> import mock <EOL> def test_not_under_code_review_ask_user ( qisrc_action , git_server , interact ) : <EOL> foo_repo = git_server . create_repo ( "<STR_LIT>" ) <EOL> qisrc_action ( "<STR_LIT>" , git_server . manifest_url ) <EOL> git_worktree = TestGitWorkTree ( ) <EOL> foo_proj = git_worktree . get_git_project ( "<STR_LIT:foo>" ) <EOL> foo_git = TestGit ( foo_proj . path ) <EOL> foo_git . commit_file ( "<STR_LIT>" , "<STR_LIT:a>" ) <EOL> interact . answers = [ False , True ] <EOL> qisrc_action ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:foo>" ) <EOL> _ , sha1 = foo_git . call ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , raises = False ) <EOL> ( _ , remote ) = foo_git . call ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , raises = False ) <EOL> assert remote != "<STR_LIT>" % sha1 <EOL> qisrc_action ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:foo>" ) <EOL> ( _ , remote ) = foo_git . call ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , raises = False ) <EOL> assert remote == "<STR_LIT>" % sha1 <EOL> def test_not_under_code_review_with_no_review ( qisrc_action , git_server ) : <EOL> foo_repo = git_server . create_repo ( "<STR_LIT>" ) <EOL> qisrc_action ( "<STR_LIT>" , git_server . manifest_url ) <EOL> git_worktree = TestGitWorkTree ( ) <EOL> foo_proj = git_worktree . get_git_project ( "<STR_LIT:foo>" ) <EOL> foo_git = TestGit ( foo_proj . path ) <EOL> foo_git . commit_file ( "<STR_LIT>" , "<STR_LIT:a>" ) <EOL> qisrc_action ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:foo>" ) <EOL> _ , sha1 = foo_git . call ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , raises = False ) <EOL> ( _ , remote ) = foo_git . call ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , raises = False ) <EOL> assert remote == "<STR_LIT>" % sha1 <EOL> def test_using_dash_y ( qisrc_action , git_server ) : <EOL> foo_repo = git_server . create_repo ( "<STR_LIT>" ) <EOL> qisrc_action ( "<STR_LIT>" , git_server . manifest_url ) <EOL> git_worktree = TestGitWorkTree ( ) <EOL> foo_proj = git_worktree . get_git_project ( "<STR_LIT:foo>" ) <EOL> foo_git = TestGit ( foo_proj . path ) <EOL> foo_git . commit_file ( "<STR_LIT>" , "<STR_LIT:a>" ) <EOL> qisrc_action ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:foo>" , "<STR_LIT>" ) <EOL> _ , sha1 = foo_git . call ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , raises = False ) <EOL> ( _ , remote ) = foo_git . call ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , raises = False ) <EOL> assert remote == "<STR_LIT>" % sha1 <EOL> def test_publish_changes ( qisrc_action , git_server ) : <EOL> foo_repo = git_server . create_repo ( "<STR_LIT>" , review = True ) <EOL> qisrc_action ( "<STR_LIT>" , git_server . manifest_url ) <EOL> git_worktree = TestGitWorkTree ( ) <EOL> foo_proj = git_worktree . get_git_project ( "<STR_LIT:foo>" ) <EOL> foo_git = TestGit ( foo_proj . path ) <EOL> foo_git . commit_file ( "<STR_LIT>" , "<STR_LIT:a>" ) <EOL> qisrc_action ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:foo>" ) <EOL> _ , sha1 = foo_git . call ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , raises = False ) <EOL> ( _ , remote ) = foo_git . call ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , raises = False ) <EOL> assert remote == "<STR_LIT>" % sha1 <EOL> def test_publish_drafts ( qisrc_action , git_server ) : <EOL> foo_repo = git_server . create_repo ( "<STR_LIT>" , review = True ) <EOL> qisrc_action ( "<STR_LIT>" , git_server . manifest_url ) <EOL> git_worktree = TestGitWorkTree ( ) <EOL> foo_proj = git_worktree . get_git_project ( "<STR_LIT:foo>" ) <EOL> foo_git = TestGit ( foo_proj . path ) <EOL> foo_git . commit_file ( "<STR_LIT>" , "<STR_LIT:a>" ) <EOL> qisrc_action ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:foo>" , "<STR_LIT>" ) <EOL> _ , sha1 = foo_git . call ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , raises = False ) <EOL> ( _ , remote ) = foo_git . call ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , raises = False ) <EOL> assert remote == "<STR_LIT>" % sha1 <EOL> def test_using_carbon_copy ( qisrc_action , git_server ) : <EOL> foo_repo = git_server . create_repo ( "<STR_LIT>" , review = True ) <EOL> qisrc_action ( "<STR_LIT>" , git_server . manifest_url ) <EOL> git_worktree = TestGitWorkTree ( ) <EOL> foo_proj = git_worktree . get_git_project ( "<STR_LIT:foo>" ) <EOL> foo_git = TestGit ( foo_proj . path ) <EOL> foo_git . fetch ( "<STR_LIT>" ) <EOL> foo_git . commit_file ( "<STR_LIT>" , "<STR_LIT:a>" ) <EOL> with mock . patch . object ( qisys . command , "<STR_LIT>" ) as mocked_call : <EOL> qisrc_action ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:foo>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> set_reviewers_args = mocked_call . call_args_list [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] [ <NUM_LIT:7> ] <EOL> assert "<STR_LIT>" in set_reviewers_args <EOL> def test_alert_maintainers ( qisrc_action , git_server ) : <EOL> foo_repo = git_server . create_repo ( "<STR_LIT>" , review = True ) <EOL> qiproject_xml = """<STR_LIT>""" <EOL> git_server . push_file ( "<STR_LIT>" , "<STR_LIT>" , qiproject_xml ) <EOL> qisrc_action ( "<STR_LIT>" , git_server . manifest_url ) <EOL> git_worktree = TestGitWorkTree ( ) <EOL> foo_proj = git_worktree . get_git_project ( "<STR_LIT:foo>" ) <EOL> foo_git = TestGit ( foo_proj . path ) <EOL> foo_git . fetch ( "<STR_LIT>" ) <EOL> foo_git . commit_file ( "<STR_LIT>" , "<STR_LIT:a>" ) <EOL> with mock . patch . object ( qisys . command , "<STR_LIT>" ) as mocked_call : <EOL> qisrc_action ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:foo>" ) <EOL> set_reviewers_args = mocked_call . call_args_list [ - <NUM_LIT:1> ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] [ - <NUM_LIT:1> ] <EOL> assert "<STR_LIT>" in set_reviewers_args <EOL> assert not "<STR_LIT>" in set_reviewers_args <EOL> def test_on_new_project ( qisrc_action , git_server , tmpdir , interact ) : <EOL> foo_repo = git_server . create_repo ( "<STR_LIT>" ) <EOL> foo_path = tmpdir . join ( "<STR_LIT>" ) . join ( "<STR_LIT:foo>" ) <EOL> foo_path . ensure ( dir = True ) <EOL> git = qisrc . git . Git ( foo_path . strpath ) <EOL> git . clone ( foo_repo . clone_url ) <EOL> interact . answers = [ True ] <EOL> with qisys . sh . change_cwd ( foo_path . strpath ) : <EOL> qisrc_action ( "<STR_LIT>" , retcode = True ) <EOL> assert not foo_path . join ( "<STR_LIT>" ) . check ( file = True ) <EOL> def test_pushing_from_perso_branch ( qisrc_action , git_server ) : <EOL> foo_repo = git_server . create_repo ( "<STR_LIT>" , review = True ) <EOL> qisrc_action ( "<STR_LIT>" , git_server . manifest_url ) <EOL> git_worktree = TestGitWorkTree ( ) <EOL> foo_proj = git_worktree . get_git_project ( "<STR_LIT:foo>" ) <EOL> foo_git = TestGit ( foo_proj . path ) <EOL> foo_git . checkout ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> foo_git . commit_file ( "<STR_LIT>" , "<STR_LIT:a>" ) <EOL> qisrc_action ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:foo>" , "<STR_LIT>" ) <EOL> _ , sha1 = foo_git . call ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , raises = False ) <EOL> ( _ , remote ) = foo_git . call ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , raises = False ) <EOL> assert remote == "<STR_LIT>" % sha1 <EOL> def test_pushing_custom_ref ( qisrc_action , git_server ) : <EOL> foo_repo = git_server . create_repo ( "<STR_LIT>" , review = True ) <EOL> qisrc_action ( "<STR_LIT>" , git_server . manifest_url ) <EOL> git_worktree = TestGitWorkTree ( ) <EOL> foo_proj = git_worktree . get_git_project ( "<STR_LIT:foo>" ) <EOL> foo_git = TestGit ( foo_proj . path ) <EOL> foo_git . checkout ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> foo_git . commit_file ( "<STR_LIT>" , "<STR_LIT:a>" ) <EOL> _ , sha1 = foo_git . call ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , raises = False ) <EOL> foo_git . commit_file ( "<STR_LIT>" , "<STR_LIT:b>" ) <EOL> qisrc_action ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:foo>" , "<STR_LIT>" ) <EOL> ( _ , remote ) = foo_git . call ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , raises = False ) <EOL> assert remote == "<STR_LIT>" % sha1 <EOL> def test_orphaned_project ( qisrc_action , git_server , record_messages ) : <EOL> foo_repo = git_server . create_repo ( "<STR_LIT>" , review = True ) <EOL> qiproject_xml = """<STR_LIT>""" <EOL> git_server . push_file ( "<STR_LIT>" , "<STR_LIT>" , qiproject_xml ) <EOL> qisrc_action ( "<STR_LIT>" , git_server . manifest_url ) <EOL> git_worktree = TestGitWorkTree ( ) <EOL> foo_proj = git_worktree . get_git_project ( "<STR_LIT:foo>" ) <EOL> foo_git = TestGit ( foo_proj . path ) <EOL> foo_git . fetch ( "<STR_LIT>" ) <EOL> foo_git . commit_file ( "<STR_LIT>" , "<STR_LIT:a>" ) <EOL> record_messages . reset ( ) <EOL> qisrc_action ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:foo>" ) <EOL> assert record_messages . find ( "<STR_LIT>" ) </s>
