def test_prune_contained_by_intersection(self, fake_p, fake_d): """ Verify nothing is merged with passed branch, therefore nothing is pruned. """ # first call is to get branch commit # 2nd call is to find branches containing the commit fake_p.expects_call().returns( '* master 123456 0.0.1 some feature commit message' ).next_call().returns( '* master\n'\ ' stage\n'\ ' feature_branch\n'\ ' feature_two_branch\n'\ ' feature_three_branch\n' ).next_call().returns( ' stage 654321 0.0.1 some feature commit message' ).next_call().returns( '* master\n'\ ' stage\n'\ ' feature_branch\n'\ ' feature_two_branch\n'\ ' feature_four_branch\n' ) fake_d.expects_call().with_args(set(['feature_branch', 'feature_two_branch'])) sys.argv = ['forgit', 'contained-by', 'master', 'stage'] forgit.handle_command_line()
def test_unknown_command(self): sys.argv = ['forgit', 'unknown'] try: forgit.handle_command_line() assert False, 'Failed to raise DocoptExit' except DocoptExit as de: assert de.args[0] == 'Usage:\n'\ ' forgit mode [<repo_path>]\n'\ ' forgit contained-by [<branches>...] [-c <config>]'
def test_contained_by_prunes_nothing(self, fake_p, fake_d): """ Verify nothing is merged with passed branch, therefore nothing is pruned. """ # first call is to get branch commit # 2nd call is to find branches containing the commit fake_p.expects_call().returns( ' master fe942c68f40bc162746885a07ff4e40d6eeace7f 0.0.1 some feature commit message' ).next_call().returns( '* master\n' ) fake_d.expects_call().with_args(set()) sys.argv = ['forgit', 'contained-by', 'master'] forgit.handle_command_line()
def test_called_with_branches(self, fake_forgit): sys.argv = ['forgit', 'contained-by', 'master', 'stage', '-c', 'local.py'] fake_forgit.expects_call().with_args( command='contained_by', config='local.py', branches=['master', 'stage'], repo_path=None).returns(True) forgit.handle_command_line()
def test_mode_called_with_repo_path(self, fake_forgit): sys.argv = ['forgit', 'mode', '/path/repo'] fake_forgit.expects_call().with_args( command='mode', config='.forgitrc', branches=[], repo_path='/path/repo').returns(True) forgit.handle_command_line()
def test_mode_called(self, fake_forgit): sys.argv = ['forgit', 'mode'] fake_forgit.expects_call().returns(True) forgit.handle_command_line()
def test_contained_by_called(self, fake_forgit): sys.argv = ['forgit', 'contained-by'] fake_forgit.expects_call().returns(True) forgit.handle_command_line()