def down_emptyfile(): diffmodel = FakeDiffModel() diffmodel.lines = [ DiffLine(None, "line 1 here", difflinetypes.ADD), DiffLine(None, "line 2 here", difflinetypes.ADD), ] view = NCursesView(diffmodel) view.win_width = 40 view.win_height = 3 actions = [ curses.KEY_DOWN, curses.KEY_DOWN, curses.KEY_DOWN, curses.KEY_DOWN, curses.KEY_DOWN, curses.KEY_DOWN, curses.KEY_DOWN, curses.KEY_DOWN, curses.KEY_DOWN, curses.KEY_DOWN, curses.KEY_DOWN, ] assert_strings_equal( view.show(actions)[0], """[m]..................[ai] + [a]line 1 here [mi]..................[ai] + [a]line 2 here [n] """, )
def mixture(): diffmodel = FakeDiffModel() diffmodel.lines = [ DiffLine( "line 1 here", "line 1 here", difflinetypes.IDENTICAL ), DiffLine( None, "line 2 here", difflinetypes.ADD ), DiffLine( "line 3 here", "line 3 here", difflinetypes.IDENTICAL ), DiffLine( "line 4 here", "line 4 here different", difflinetypes.DIFFERENT ), DiffLine( "line 5 here", None, difflinetypes.REMOVE ), DiffLine( "line 6 here", "line 6 here", difflinetypes.IDENTICAL ), ] view = NCursesView( diffmodel ) view.win_width = 40 view.win_height = 5 actions = [] assert_strings_equal( view.show( actions )[0], """[ni]line 1 here [n] line 1 here [m]..................[ai] + [a]line 2 here [n]line 3 here line 3 here [d]line 4 here [di] * [d]line 4 here differe [r]line 5 here [ri] - [m]................... """ )
def display_edited_lines(): diffmodel = FakeDiffModel() diffmodel.lines = [ DiffLine( "left 01", "right 01", difflinetypes.DIFFERENT, False, True ), DiffLine( "left 02", "right 02", difflinetypes.DIFFERENT, True, True ), DiffLine( "left 03", "right 03", difflinetypes.DIFFERENT, True, False ), DiffLine( "line 04", "line 04", difflinetypes.IDENTICAL, False, True ), DiffLine( "line 05", "line 05", difflinetypes.IDENTICAL, True, True ), DiffLine( "line 06", "line 06", difflinetypes.IDENTICAL, True, False ), ] view = NCursesView( diffmodel ) view.win_width = 40 view.win_height = 6 actions = [] assert_strings_equal( view.show( actions )[0], """[di]left 01 [ei] * [e]right 01 left 02 [ei] * [e]right 02 left 03 [ei] * [d]right 03 [n]line 04 [ei] [e]line 04 line 05 [ei] [e]line 05 line 06 [ei] [n]line 06 """ )
def exit_edit_mode(): diffmodel = EditReportingFakeDiffModel() view = NCursesView( diffmodel ) view.win_width = 40 view.win_height = 5 actions = [ "e", keys.KEY_ESCAPE ] (window, header, status ) = view.show( actions ) assert_strings_equal( status, """[ni] Press SHIFT-H for help """ )
def enter_edit_mode(): diffmodel = EditReportingFakeDiffModel() view = NCursesView( diffmodel ) view.win_width = 50 view.win_height = 5 actions = [ "e" ] (window, header, status ) = view.show( actions ) assert_strings_equal( status, """[mi] Editing line. Press ESC to finish. """ )
def default_message_at_start(): diffmodel = FakeDiffModel() diffmodel.lines = [] view = NCursesView( diffmodel ) view.win_width = 40 view.win_height = 5 actions = [] assert_strings_equal( view.show( actions )[2], """[ni] Press SHIFT-H for help """ )
def help(): diffmodel = FakeDiffModel() diffmodel.lines = [] view = NCursesView( diffmodel ) view.win_width = 40 view.win_height = 40 actions = [ "H" ] assert_strings_equal( view.show( actions )[2], """[ni] Press any key to continue """ )
def header_short_names(): diffmodel = FakeDiffModel() diffmodel.lines = [] view = NCursesView( diffmodel, "dir1/file1.txt", "dir2/file2.txt" ) view.win_width = 40 view.win_height = 5 actions = [] assert_strings_equal( view.show( actions )[1], """[ni]dir1/file1.txt dir2/file2.txt """ )
def default_message_after_move(): diffmodel = FakeDiffModel() diffmodel.lines = [] filemanager = AlwaysSaveFileManager() view = NCursesView( diffmodel, None, None, filemanager ) view.win_width = 40 view.win_height = 5 actions = [ "s", "j" ] assert_strings_equal( view.show( actions )[2], """[ni] Press SHIFT-H for help """ )
def no_need_to_save(): diffmodel = FakeDiffModel() diffmodel.lines = [] filemanager = NeverSaveFileManager() view = NCursesView( diffmodel, None, None, filemanager ) view.win_width = 40 view.win_height = 5 actions = [ "s" ] assert_strings_equal( view.show( actions )[2], """[mi] No changes were made in this file. """ )
def file_saved(): diffmodel = FakeDiffModel() diffmodel.lines = [] filemanager = AlwaysSaveFileManager() view = NCursesView( diffmodel, None, None, filemanager ) view.win_width = 40 view.win_height = 5 actions = [ "s" ] assert_strings_equal( view.show( actions )[2], """[mi] File saved. """ )
def header_long_names(): diffmodel = FakeDiffModel() diffmodel.lines = [] view = NCursesView( diffmodel, "dir1/dir2/dir3/dir4/dir5/file1.txt", "dira/dirb/dirc/dird/dire/file2.txt" ) view.win_width = 40 view.win_height = 5 actions = [] assert_strings_equal( view.show( actions )[1], """[ni].../dir5/file1.txt ...d/dire/file2.txt """ )
def display_file_modified_both(): diffmodel = EditReportingFakeDiffModel() diffmodel.has_edit[ directions.LEFT ] = True diffmodel.has_edit[ directions.RIGHT ] = True view = NCursesView( diffmodel ) view.win_width = 60 view.win_height = 5 view.filename_left = "filename_left.txt" view.filename_right = "filename_right.txt" actions = [] (window, header, status ) = view.show( actions ) assert_strings_equal( header, "[ni]*filename_left.txt *filename_right.txt \n" )
def at_first_difference(): diffmodel = FakeDiffModel() diffmodel.lines = [ DiffLine( "line 01", "line 01", difflinetypes.IDENTICAL ), DiffLine( "line 02", "line 02", difflinetypes.DIFFERENT ), DiffLine( "line 03", "line 03", difflinetypes.IDENTICAL ), ] view = NCursesView( diffmodel ) view.win_width = 40 view.win_height = 5 actions = [ "n", "p" ] assert_strings_equal( view.show( actions )[2], """[mi] At first difference """ )
def same(): diffmodel = FakeDiffModel() diffmodel.lines = [ DiffLine( "line 1 here", "line 1 here", difflinetypes.IDENTICAL ), DiffLine( "line 2 here", "line 2 here", difflinetypes.IDENTICAL ), ] view = NCursesView( diffmodel ) view.win_width = 40 view.win_height = 5 actions = [] assert_strings_equal( view.show( actions )[0], """[ni]line 1 here [n] line 1 here line 2 here line 2 here """ )
def removes(): diffmodel = FakeDiffModel() diffmodel.lines = [ DiffLine( "line 1 here", None, difflinetypes.REMOVE ), DiffLine( "line 2 here", None, difflinetypes.REMOVE ), ] view = NCursesView( diffmodel ) view.win_width = 39 view.win_height = 5 actions = [] assert_strings_equal( view.show( actions )[0], """[ri]line 1 here - [m].................. [r]line 2 here [ri] - [m].................. [n] """ )
def adds(): diffmodel = FakeDiffModel() diffmodel.lines = [ DiffLine( None, "line 1 here", difflinetypes.ADD ), DiffLine( None, "line 2 here", difflinetypes.ADD ), ] view = NCursesView( diffmodel ) view.win_width = 40 view.win_height = 5 actions = [] assert_strings_equal( view.show( actions )[0], """[mi]..................[ai] + [a]line 1 here [m]..................[ai] + [a]line 2 here [n] """ )
def differences(): diffmodel = FakeDiffModel() diffmodel.lines = [ DiffLine( "line 1 here", "line 1 here different", difflinetypes.DIFFERENT ), DiffLine( "line 2 here", "line 2 here different", difflinetypes.DIFFERENT ), ] view = NCursesView( diffmodel ) view.win_width = 40 view.win_height = 5 actions = [] assert_strings_equal( view.show( actions )[0], """[di]line 1 here * [d]line 1 here differe line 2 here [di] * [d]line 2 here differe [n] """ )
def run_ncursesview( diffmodel, filename_left, filename_right, filemanager, sendkeys ): ncursesview = NCursesView( diffmodel, filename_left, filename_right, filemanager ) ncursesview.show( sendkeys )