<s> from __future__ import with_statement <EOL> import datetime <EOL> import vcs <EOL> from vcs . utils . compat import unittest <EOL> from vcs . nodes import FileNode <EOL> from vcs . tests . base import BackendTestMixin <EOL> from vcs . tests . conf import SCM_TESTS <EOL> class BranchesTestCaseMixin ( BackendTestMixin ) : <EOL> @ classmethod <EOL> def _get_commits ( cls ) : <EOL> commits = [ <EOL> { <EOL> '<STR_LIT:message>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:date>' : datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:20> ) , <EOL> '<STR_LIT>' : [ <EOL> FileNode ( '<STR_LIT>' , content = '<STR_LIT>' ) , <EOL> FileNode ( '<STR_LIT>' , content = '<STR_LIT>' ) , <EOL> FileNode ( '<STR_LIT>' , content = '<STR_LIT>' ) , <EOL> ] , <EOL> } , <EOL> { <EOL> '<STR_LIT:message>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:date>' : datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT> ) , <EOL> '<STR_LIT>' : [ <EOL> FileNode ( '<STR_LIT>' , content = '<STR_LIT>' ) , <EOL> ] , <EOL> '<STR_LIT>' : [ <EOL> FileNode ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] , <EOL> '<STR_LIT>' : [ ] , <EOL> } , <EOL> ] <EOL> return commits <EOL> def test_simple ( self ) : <EOL> tip = self . repo . get_changeset ( ) <EOL> self . assertEqual ( tip . date , datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT> ) ) <EOL> def test_new_branch ( self ) : <EOL> self . assertFalse ( '<STR_LIT>' in self . repo . branches ) <EOL> self . imc . add ( vcs . nodes . FileNode ( '<STR_LIT>' , <EOL> content = '<STR_LIT>' ) ) <EOL> foobar_tip = self . imc . commit ( <EOL> message = u'<STR_LIT>' , <EOL> author = u'<STR_LIT>' , <EOL> branch = '<STR_LIT>' , <EOL> ) <EOL> self . assertTrue ( '<STR_LIT>' in self . repo . branches ) <EOL> self . assertEqual ( foobar_tip . branch , '<STR_LIT>' ) <EOL> def test_new_head ( self ) : <EOL> tip = self . repo . get_changeset ( ) <EOL> self . imc . add ( vcs . nodes . FileNode ( '<STR_LIT>' , <EOL> content = '<STR_LIT>' ) ) <EOL> foobar_tip = self . imc . commit ( <EOL> message = u'<STR_LIT>' , <EOL> author = u'<STR_LIT>' , <EOL> branch = '<STR_LIT>' , <EOL> parents = [ tip ] , <EOL> ) <EOL> self . imc . change ( vcs . nodes . FileNode ( '<STR_LIT>' , <EOL> content = '<STR_LIT>' ) ) <EOL> newtip = self . imc . commit ( <EOL> message = u'<STR_LIT>' , <EOL> author = u'<STR_LIT>' , <EOL> branch = foobar_tip . branch , <EOL> parents = [ foobar_tip ] , <EOL> ) <EOL> newest_tip = self . imc . commit ( <EOL> message = u'<STR_LIT>' % foobar_tip . raw_id , <EOL> author = u'<STR_LIT>' , <EOL> branch = self . backend_class . DEFAULT_BRANCH_NAME , <EOL> parents = [ newtip , foobar_tip ] , <EOL> ) <EOL> self . assertEqual ( newest_tip . branch , <EOL> self . backend_class . DEFAULT_BRANCH_NAME ) <EOL> def test_branch_with_slash_in_name ( self ) : <EOL> self . imc . add ( vcs . nodes . FileNode ( '<STR_LIT>' , content = '<STR_LIT>' ) ) <EOL> self . imc . commit ( u'<STR_LIT>' , author = u'<STR_LIT>' , <EOL> branch = '<STR_LIT>' ) <EOL> self . assertTrue ( '<STR_LIT>' in self . repo . branches ) <EOL> def test_branch_with_slash_in_name_and_similar_without ( self ) : <EOL> self . imc . add ( vcs . nodes . FileNode ( '<STR_LIT>' , content = '<STR_LIT>' ) ) <EOL> self . imc . commit ( u'<STR_LIT>' , author = u'<STR_LIT>' , <EOL> branch = '<STR_LIT>' ) <EOL> self . imc . add ( vcs . nodes . FileNode ( '<STR_LIT>' , content = '<STR_LIT>' ) ) <EOL> self . imc . commit ( u'<STR_LIT>' , author = u'<STR_LIT>' , <EOL> branch = '<STR_LIT>' ) <EOL> self . assertIn ( '<STR_LIT>' , self . repo . branches ) <EOL> self . assertIn ( '<STR_LIT>' , self . repo . branches ) <EOL> for alias in SCM_TESTS : <EOL> attrs = { <EOL> '<STR_LIT>' : alias , <EOL> } <EOL> cls_name = '<STR_LIT>' . join ( ( '<STR_LIT>' % alias ) . title ( ) . split ( ) ) <EOL> bases = ( BranchesTestCaseMixin , unittest . TestCase ) <EOL> globals ( ) [ cls_name ] = type ( cls_name , bases , attrs ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
