<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> from __future__ import division <EOL> from __future__ import print_function <EOL> import os <EOL> import unittest <EOL> import phlgit_branch <EOL> import phlgit_push <EOL> import phlgit_revparse <EOL> import phlgitu_fixture <EOL> import phlgitx_refcache <EOL> import abdt_branch <EOL> import abdt_branchtester <EOL> import abdt_classicnaming <EOL> import abdt_differresultcache <EOL> import abdt_git <EOL> import abdt_naming <EOL> class Test ( unittest . TestCase ) : <EOL> def __init__ ( self , data ) : <EOL> super ( Test , self ) . __init__ ( data ) <EOL> self . repos = None <EOL> self . repo_central = None <EOL> self . repo_dev = None <EOL> self . repo_arcyd = None <EOL> def setUp ( self ) : <EOL> self . repos = phlgitu_fixture . CentralisedWithTwoWorkers ( ) <EOL> self . repo_central = self . repos . central_repo <EOL> self . repo_dev = self . repos . w0 . repo <EOL> sys_repo = self . repos . w1 . repo <EOL> refcache_repo = phlgitx_refcache . Repo ( sys_repo ) <EOL> differ_cache = abdt_differresultcache . Cache ( refcache_repo ) <EOL> self . repo_arcyd = abdt_git . Repo ( <EOL> refcache_repo , differ_cache , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def tearDown ( self ) : <EOL> self . repos . close ( ) <EOL> def test_A_Breathing ( self ) : <EOL> pass <EOL> def test_B_Empty ( self ) : <EOL> pass <EOL> def test_C_BadPreReviewToNew ( self ) : <EOL> base , branch_name , branch = self . _setup_for_untracked_branch ( ) <EOL> transition_list = [ <EOL> branch . mark_ok_new_review , branch . mark_new_bad_in_review <EOL> ] <EOL> for do_transition in transition_list : <EOL> branches = phlgit_branch . get_remote ( self . repo_arcyd , '<STR_LIT>' ) <EOL> branch . mark_bad_pre_review ( ) <EOL> branches_bad_pre = phlgit_branch . get_remote ( <EOL> self . repo_arcyd , '<STR_LIT>' ) <EOL> do_transition ( <NUM_LIT> ) <EOL> branches_new = phlgit_branch . get_remote ( self . repo_arcyd , '<STR_LIT>' ) <EOL> self . assertEqual ( len ( branches_bad_pre ) , len ( branches ) + <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( branches_bad_pre ) , len ( branches_new ) ) <EOL> branch . clear_mark ( ) <EOL> branches_cleared = phlgit_branch . get_remote ( <EOL> self . repo_arcyd , '<STR_LIT>' ) <EOL> self . assertEqual ( len ( branches_cleared ) , len ( branches ) ) <EOL> def test_D_AlternatingAuthors ( self ) : <EOL> base , branch_name , branch = self . _setup_for_untracked_branch ( ) <EOL> alice_user = '<STR_LIT>' <EOL> alice_email = '<STR_LIT>' <EOL> bob_user = '<STR_LIT>' <EOL> bob_email = '<STR_LIT>' <EOL> self . _dev_commit_new_empty_file ( '<STR_LIT>' , alice_user , alice_email ) <EOL> self . _dev_commit_new_empty_file ( '<STR_LIT>' , bob_user , bob_email ) <EOL> self . _dev_commit_new_empty_file ( '<STR_LIT>' , alice_user , alice_email ) <EOL> phlgit_push . push ( self . repo_dev , branch_name , '<STR_LIT>' ) <EOL> self . repo_arcyd ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> author_names_emails = branch . get_author_names_emails ( ) <EOL> self . assertTupleEqual ( <EOL> author_names_emails [ <NUM_LIT:0> ] , <EOL> ( bob_user , bob_email ) ) <EOL> self . assertTupleEqual ( <EOL> author_names_emails [ <NUM_LIT:1> ] , <EOL> ( alice_user , alice_email ) ) <EOL> def test_E_NewCommitsDescription ( self ) : <EOL> base , branch_name , branch = self . _setup_for_untracked_branch ( ) <EOL> user = '<STR_LIT>' <EOL> email = '<STR_LIT>' <EOL> self . _dev_commit_new_empty_file ( '<STR_LIT>' , user , email ) <EOL> self . _dev_commit_new_empty_file ( '<STR_LIT>' , user , email ) <EOL> self . _dev_commit_new_empty_file ( '<STR_LIT>' , user , email ) <EOL> self . _dev_commit_new_empty_file ( '<STR_LIT>' , user , email ) <EOL> phlgit_push . push ( self . repo_dev , branch_name , '<STR_LIT>' ) <EOL> self . repo_arcyd ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> new_commits_str = branch . describe_new_commits ( ) <EOL> new_commits = new_commits_str . splitlines ( ) <EOL> self . assertEqual ( <NUM_LIT:4> , len ( new_commits ) ) <EOL> count = <NUM_LIT:4> <EOL> for line in new_commits : <EOL> self . assertTrue ( line . endswith ( '<STR_LIT>' . format ( count ) ) ) <EOL> count -= <NUM_LIT:1> <EOL> new_commits_str = branch . describe_new_commits ( <NUM_LIT:2> ) <EOL> new_commits = new_commits_str . splitlines ( ) <EOL> self . assertEqual ( <NUM_LIT:3> , len ( new_commits ) ) <EOL> self . assertTrue ( new_commits [ <NUM_LIT:0> ] . endswith ( '<STR_LIT>' ) ) <EOL> self . assertTrue ( new_commits [ <NUM_LIT:1> ] . endswith ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( new_commits [ <NUM_LIT:2> ] , '<STR_LIT>' ) <EOL> new_commits_str = branch . describe_new_commits ( <NUM_LIT:3> , <NUM_LIT:20> ) <EOL> new_commits = new_commits_str . splitlines ( ) <EOL> self . assertEqual ( <NUM_LIT:2> , len ( new_commits ) ) <EOL> self . assertTrue ( new_commits [ <NUM_LIT:0> ] . endswith ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( new_commits [ <NUM_LIT:1> ] , '<STR_LIT>' ) <EOL> def _dev_commit_new_empty_file ( self , filename , user , email ) : <EOL> self . _create_new_file ( self . repo_dev , filename ) <EOL> self . repo_dev ( '<STR_LIT>' , filename ) <EOL> self . repo_dev ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> filename , <EOL> '<STR_LIT>' + '<STR_LIT>' . format ( user , email ) ) <EOL> def test_XB_UntrackedBranch ( self ) : <EOL> abdt_branchtester . check_XB_UntrackedBranch ( self ) <EOL> def test_XC_MoveBetweenAllMarkedStates ( self ) : <EOL> abdt_branchtester . check_XC_MoveBetweenAllMarkedStates ( self ) <EOL> def check_D_SetRetrieveRepoNameBranchLink ( self ) : <EOL> abdt_branchtester . check_XD_SetRetrieveRepoNameBranchLink ( self ) <EOL> def _create_new_file ( self , repo , filename ) : <EOL> self . assertFalse ( os . path . isfile ( filename ) ) <EOL> open ( os . path . join ( repo . working_dir , filename ) , '<STR_LIT:a>' ) . close ( ) <EOL> def _setup_for_tracked_branch ( self ) : <EOL> base , branch_name , branch = self . _setup_for_untracked_branch ( ) <EOL> branch . mark_ok_new_review ( <NUM_LIT> ) <EOL> return base , branch_name , branch <EOL> def _setup_for_untracked_branch ( self , repo_name = '<STR_LIT:name>' , branch_url = None ) : <EOL> base = abdt_naming . EXAMPLE_REVIEW_BRANCH_BASE <EOL> naming = abdt_classicnaming . Naming ( ) <EOL> branch_name = abdt_classicnaming . EXAMPLE_REVIEW_BRANCH_NAME <EOL> self . repo_dev ( '<STR_LIT>' , '<STR_LIT>' , branch_name ) <EOL> phlgit_push . push ( self . repo_dev , branch_name , '<STR_LIT>' ) <EOL> self . repo_arcyd ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> review_branch = naming . make_review_branch_from_name ( branch_name ) <EOL> review_hash = phlgit_revparse . get_sha1_or_none ( <EOL> self . repo_arcyd , review_branch . branch ) <EOL> branch = abdt_branch . Branch ( <EOL> self . repo_arcyd , <EOL> review_branch , <EOL> review_hash , <EOL> None , <EOL> None , <EOL> None , <EOL> repo_name , <EOL> branch_url ) <EOL> branch . verify_review_branch_base ( ) <EOL> return base , branch_name , branch </s>
