<s> from unittest import TestCase <EOL> from gitbrowse . git import GitFileHistory <EOL> class GitTestCase ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . file_history = GitFileHistory ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def test_commits ( self ) : <EOL> self . assertEquals ( <EOL> [ c . message for c in self . file_history . commits ] , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] , <EOL> '<STR_LIT>' , <EOL> ) <EOL> def test_navigation ( self ) : <EOL> commits = self . file_history . commits <EOL> self . assertEquals ( self . file_history . current_commit , commits [ <NUM_LIT:0> ] ) <EOL> self . file_history . prev ( ) <EOL> self . assertEquals ( self . file_history . current_commit , commits [ <NUM_LIT:1> ] ) <EOL> self . file_history . prev ( ) <EOL> self . assertEquals ( self . file_history . current_commit , commits [ <NUM_LIT:2> ] ) <EOL> self . file_history . next ( ) <EOL> self . assertEquals ( self . file_history . current_commit , commits [ <NUM_LIT:1> ] ) <EOL> def test_navigation_beyond_end ( self ) : <EOL> commits = self . file_history . commits <EOL> self . assertEquals ( self . file_history . current_commit , commits [ <NUM_LIT:0> ] ) <EOL> self . file_history . next ( ) <EOL> self . assertEquals ( self . file_history . current_commit , commits [ <NUM_LIT:0> ] ) <EOL> def test_navigation_before_start ( self ) : <EOL> commits = self . file_history . commits <EOL> for _ in range ( <NUM_LIT:4> ) : <EOL> self . file_history . prev ( ) <EOL> self . assertEquals ( self . file_history . current_commit , commits [ <NUM_LIT:4> ] ) <EOL> self . file_history . prev ( ) <EOL> self . assertEquals ( self . file_history . current_commit , commits [ <NUM_LIT:4> ] ) <EOL> def test_blame ( self ) : <EOL> commits = self . file_history . commits <EOL> for _ in range ( <NUM_LIT:5> ) : <EOL> self . file_history . prev ( ) <EOL> def check_blame ( lines , expected_commits ) : <EOL> blame = self . file_history . blame ( ) <EOL> for blame_line , expected_line , expected_commit in zip ( blame , lines , expected_commits ) : <EOL> self . assertEquals ( blame_line . line , expected_line ) <EOL> self . assertEquals ( blame_line . sha , commits [ expected_commit ] . sha ) <EOL> check_blame ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ <NUM_LIT:4> , <NUM_LIT:4> , <NUM_LIT:4> , <NUM_LIT:4> , <NUM_LIT:4> ] , <EOL> ) <EOL> self . file_history . next ( ) <EOL> check_blame ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ <NUM_LIT:4> , <NUM_LIT:4> , <NUM_LIT:4> ] , <EOL> ) <EOL> self . file_history . next ( ) <EOL> check_blame ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:4> , <NUM_LIT:4> ] , <EOL> ) <EOL> self . file_history . next ( ) <EOL> check_blame ( <EOL> [ '<STR_LIT>' , '<STR_LIT:\n>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:\n>' , <EOL> '<STR_LIT>' ] , <EOL> [ <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:4> , <NUM_LIT:1> , <NUM_LIT:4> ] , <EOL> ) <EOL> self . file_history . next ( ) <EOL> check_blame ( <EOL> [ '<STR_LIT>' , '<STR_LIT:\n>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] , <EOL> [ <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:4> , <NUM_LIT:4> ] , <EOL> ) <EOL> def test_forward_line_mappings ( self ) : <EOL> commits = self . file_history . commits <EOL> self . assertEquals ( <EOL> { <NUM_LIT:0> : <NUM_LIT:0> , <NUM_LIT:1> : None , <NUM_LIT:2> : None , <NUM_LIT:3> : <NUM_LIT:1> , <NUM_LIT:4> : <NUM_LIT:2> , <NUM_LIT:5> : <NUM_LIT:3> } , <EOL> self . file_history . line_mapping ( commits [ <NUM_LIT:4> ] . sha , commits [ <NUM_LIT:3> ] . sha ) , <EOL> ) <EOL> self . assertEquals ( <EOL> { <NUM_LIT:0> : <NUM_LIT:2> , <NUM_LIT:1> : <NUM_LIT:3> , <NUM_LIT:2> : <NUM_LIT:4> , <NUM_LIT:3> : <NUM_LIT:5> } , <EOL> self . file_history . line_mapping ( commits [ <NUM_LIT:3> ] . sha , commits [ <NUM_LIT:2> ] . sha ) , <EOL> ) <EOL> self . assertEquals ( <EOL> { <NUM_LIT:0> : <NUM_LIT:0> , <NUM_LIT:1> : <NUM_LIT:2> , <NUM_LIT:2> : <NUM_LIT:3> , <NUM_LIT:3> : <NUM_LIT:4> , <NUM_LIT:4> : <NUM_LIT:6> , <NUM_LIT:5> : <NUM_LIT:7> } , <EOL> self . file_history . line_mapping ( commits [ <NUM_LIT:2> ] . sha , commits [ <NUM_LIT:1> ] . sha ) , <EOL> ) <EOL> self . assertEquals ( <EOL> { <NUM_LIT:0> : <NUM_LIT:0> , <NUM_LIT:1> : <NUM_LIT:1> , <NUM_LIT:2> : <NUM_LIT:2> , <NUM_LIT:3> : <NUM_LIT:3> , <NUM_LIT:4> : <NUM_LIT:4> , <NUM_LIT:5> : None , <NUM_LIT:6> : <NUM_LIT:5> , <NUM_LIT:7> : <NUM_LIT:6> } , <EOL> self . file_history . line_mapping ( commits [ <NUM_LIT:1> ] . sha , commits [ <NUM_LIT:0> ] . sha ) , <EOL> ) <EOL> def test_reverse_line_mappings ( self ) : <EOL> commits = self . file_history . commits <EOL> self . assertEquals ( <EOL> { <NUM_LIT:0> : <NUM_LIT:0> , <NUM_LIT:1> : <NUM_LIT:1> , <NUM_LIT:2> : <NUM_LIT:2> , <NUM_LIT:3> : <NUM_LIT:3> , <NUM_LIT:4> : <NUM_LIT:4> , <NUM_LIT:5> : <NUM_LIT:6> , <NUM_LIT:6> : <NUM_LIT:7> } , <EOL> self . file_history . line_mapping ( commits [ <NUM_LIT:0> ] . sha , commits [ <NUM_LIT:1> ] . sha ) , <EOL> ) <EOL> self . assertEquals ( <EOL> { <NUM_LIT:0> : <NUM_LIT:0> , <NUM_LIT:1> : None , <NUM_LIT:2> : <NUM_LIT:1> , <NUM_LIT:3> : <NUM_LIT:2> , <NUM_LIT:4> : <NUM_LIT:3> , <NUM_LIT:5> : None , <NUM_LIT:6> : <NUM_LIT:4> , <NUM_LIT:7> : <NUM_LIT:5> } , <EOL> self . file_history . line_mapping ( commits [ <NUM_LIT:1> ] . sha , commits [ <NUM_LIT:2> ] . sha ) , <EOL> ) <EOL> self . assertEquals ( <EOL> { <NUM_LIT:0> : None , <NUM_LIT:1> : None , <NUM_LIT:2> : <NUM_LIT:0> , <NUM_LIT:3> : <NUM_LIT:1> , <NUM_LIT:4> : <NUM_LIT:2> , <NUM_LIT:5> : <NUM_LIT:3> } , <EOL> self . file_history . line_mapping ( commits [ <NUM_LIT:2> ] . sha , commits [ <NUM_LIT:3> ] . sha ) , <EOL> ) <EOL> self . assertEquals ( <EOL> { <NUM_LIT:0> : <NUM_LIT:0> , <NUM_LIT:1> : <NUM_LIT:3> , <NUM_LIT:2> : <NUM_LIT:4> , <NUM_LIT:3> : <NUM_LIT:5> } , <EOL> self . file_history . line_mapping ( commits [ <NUM_LIT:3> ] . sha , commits [ <NUM_LIT:4> ] . sha ) , <EOL> ) </s>
