Ejemplo n.º 1
0
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 _make_manydiffs_view():
	diffmodel = FakeDiffModel()
	diffmodel.lines = [
		DiffLine( "line 01", "line 01", difflinetypes.IDENTICAL ),
		DiffLine( "line 02", "diff 02", difflinetypes.DIFFERENT ),
		DiffLine( "line 03", "diff 03", difflinetypes.DIFFERENT ),
		DiffLine( "line 04", "diff 04", difflinetypes.DIFFERENT ),
		DiffLine( "line 05", "line 05", difflinetypes.IDENTICAL ),
		DiffLine( "line 06", "diff 06", difflinetypes.DIFFERENT ),
		DiffLine( "line 07", "line 07", difflinetypes.IDENTICAL ),
		DiffLine( "line 08", "diff 08", difflinetypes.DIFFERENT ),
		DiffLine( "line 09", "diff 09", difflinetypes.DIFFERENT ),
		DiffLine( "line 10", "diff 10", difflinetypes.DIFFERENT ),
		DiffLine( "line 11", "line 11", difflinetypes.IDENTICAL ),
		DiffLine( "line 12", "diff 12", difflinetypes.DIFFERENT ),
		DiffLine( "line 13", "line 13", difflinetypes.IDENTICAL ),
		DiffLine( "line 14", "line 14", difflinetypes.IDENTICAL ),
		DiffLine( "line 15", "line 15", difflinetypes.IDENTICAL ),
		DiffLine( "line 16", "line 16", difflinetypes.IDENTICAL ),
		DiffLine( "line 17", "line 17", difflinetypes.IDENTICAL ),
	]

	view = NCursesView( diffmodel )
	view.win_width = 20
	view.win_height = 10

	return view
def _make_view():
	diffmodel = FakeDiffModel()
	diffmodel.lines = [
		DiffLine( "line 01", "line 01", difflinetypes.IDENTICAL ),
		DiffLine( "line 02", "line 02", difflinetypes.IDENTICAL ),
		DiffLine( "line 03", "line 03", difflinetypes.IDENTICAL ),
		DiffLine( "line 04", "line 04", difflinetypes.IDENTICAL ),
		DiffLine( "line 05", "line 05", difflinetypes.IDENTICAL ),
		DiffLine( "line 06", "line 06", difflinetypes.IDENTICAL ),
		DiffLine( "line 07", "line 07", difflinetypes.IDENTICAL ),
		DiffLine( "line 08", "line 08", difflinetypes.IDENTICAL ),
		DiffLine( "line 09", "line 09", difflinetypes.IDENTICAL ),
		DiffLine( "line 10", "line 10 different", difflinetypes.DIFFERENT ),
		DiffLine( "line 11", "line 11 different", difflinetypes.DIFFERENT ),
		DiffLine( "line 12", "line 12", difflinetypes.IDENTICAL ),
		DiffLine( "line 13", "line 13", difflinetypes.IDENTICAL ),
		DiffLine( None,      "line 14", difflinetypes.ADD ),
		DiffLine( None,      "line 15", difflinetypes.ADD ),
	]

	view = NCursesView( diffmodel )
	view.win_width = 20
	view.win_height = 7

	return view
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]                                        
""",
    )
Ejemplo n.º 6
0
def pad_to_width():
	diffmodel = FakeDiffModel()
	view = NCursesView( diffmodel )

	assert_strings_equal( view.pad_to_width( None, 0, 5 ), "....." )
	assert_strings_equal( view.pad_to_width( "d f", 0, 5 ), "d f  " )
	assert_strings_equal( view.pad_to_width( "d fffffffff", 0, 5 ),
		"d fffffffff" )

	assert_strings_equal( view.pad_to_width( "d fffffffff", 3, 5 ), "ffffffff" )
def _make_view():
	diffmodel = FakeDiffModel()
	diffmodel.lines = [
		DiffLine( "line 1 here", "line 1 here", difflinetypes.IDENTICAL ),
	]

	view = NCursesView( diffmodel )
	view.win_width  = 80
	view.win_height = 20

	return view
def _make_short_diff_view():
    diffmodel = FakeDiffModel()
    diffmodel.lines = [
        DiffLine("line 01", "line 01", difflinetypes.IDENTICAL),
        DiffLine("line 02", "line 02", difflinetypes.IDENTICAL),
    ]

    view = NCursesView(diffmodel)
    view.win_width = 20
    view.win_height = 4

    return view
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 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         
""" )
Ejemplo n.º 11
0
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         
""" )
Ejemplo n.º 12
0
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        
""" )
Ejemplo n.º 13
0
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
""" )
Ejemplo n.º 14
0
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     
""" )
Ejemplo n.º 15
0
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.               
""" )
Ejemplo n.º 16
0
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.   
""" )
Ejemplo n.º 17
0
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 _make_wide_view():
    diffmodel = FakeDiffModel()
    diffmodel.lines = [
        DiffLine("0-23456789abcdef", "0-23456789abcdef", difflinetypes.IDENTICAL),
        DiffLine("1-23456789abcdef", "1-23456789abcdef plus extr", difflinetypes.DIFFERENT),
        DiffLine(None, "2-23456789abcdef plus extr", difflinetypes.ADD),
        DiffLine("3-23456789abcdef", None, difflinetypes.REMOVE),
        DiffLine("4-23456789abcdef", "4-23456789abcdef", difflinetypes.IDENTICAL),
        DiffLine("5-23456789abcdef", "5-23456789abcdef plus ext", difflinetypes.DIFFERENT),
    ]

    view = NCursesView(diffmodel)
    view.win_width = 23
    view.win_height = 2

    return view
Ejemplo n.º 19
0
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           
""" )
Ejemplo n.º 20
0
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 _make_view():
	diffmodel = FakeDiffModel()
	diffmodel.lines = [
		DiffLine( "line 1 here", "line 1 here", difflinetypes.IDENTICAL ),
		DiffLine( "line 2 here", "line 2 here", difflinetypes.IDENTICAL ),
		DiffLine( "line 3 here", "line 3 here", difflinetypes.IDENTICAL ),
		DiffLine( "line 4 here", "line 4 here", difflinetypes.IDENTICAL ),
		DiffLine( "line 5 here", "line 5 here different",
			difflinetypes.DIFFERENT ),
		DiffLine( "line 6 here", "line 6 here", difflinetypes.IDENTICAL ),
		DiffLine( "line 7 here", "line 7 here", difflinetypes.IDENTICAL ),
		DiffLine( "line 8 here", "line 8 here", difflinetypes.IDENTICAL ),
		DiffLine( "line 9 here", "line 9 here", difflinetypes.IDENTICAL ),
		DiffLine( "line 10 here", "line 10 here", difflinetypes.IDENTICAL ),
		]

	view = NCursesView( diffmodel )
	view.win_width  = 40
	view.win_height = 5

	return view
def _make_view():
	diffmodel = EditTracingFakeDiffModel()
	diffmodel.lines = [
		DiffLine( "left 01", "right 01", difflinetypes.DIFFERENT ),
		DiffLine( "left 02", "right 02", difflinetypes.DIFFERENT ),
		DiffLine( "left 03", "right 03", difflinetypes.DIFFERENT ),
		DiffLine( "left 04", "right 04", difflinetypes.DIFFERENT ),
		DiffLine( "left 05", "right 05", difflinetypes.DIFFERENT ),
		DiffLine( "left 06", "right 06", difflinetypes.DIFFERENT ),
		DiffLine( "left 07", "right 07", difflinetypes.DIFFERENT ),
		DiffLine( "left 08", "right 08", difflinetypes.DIFFERENT ),
		DiffLine( "left 09", "right 09", difflinetypes.DIFFERENT ),
		DiffLine( "left 10", "right 10", difflinetypes.DIFFERENT ),
		DiffLine( "left 11", "right 11", difflinetypes.DIFFERENT ),
		DiffLine( "left 12", "right 12", difflinetypes.DIFFERENT ),
	]

	view = NCursesView( diffmodel )
	view.win_width = 20
	view.win_height = 5

	return view, diffmodel
Ejemplo n.º 23
0
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]                                       
                                       
                                       
""" )
Ejemplo n.º 24
0
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]                                        
                                        
                                        
""" )
Ejemplo n.º 25
0
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 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" )
Ejemplo n.º 27
0
def run_ncursesview( diffmodel, filename_left, filename_right, filemanager,
		sendkeys ):
	ncursesview = NCursesView( diffmodel, filename_left, filename_right,
		filemanager )
	ncursesview.show( sendkeys )