[meld/ui-next: 11/35] test: Update action mode test for ActionGutter changes



commit 0aba59d07fc74d3e1dd3f537b251426820edf45e
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Tue Feb 12 07:23:53 2019 +1000

    test: Update action mode test for ActionGutter changes

 test/test_gutterrendererchunk.py | 77 ++++++++++++++++++++--------------------
 1 file changed, 38 insertions(+), 39 deletions(-)
---
diff --git a/test/test_gutterrendererchunk.py b/test/test_gutterrendererchunk.py
index bd1e2580..6a11e6de 100644
--- a/test/test_gutterrendererchunk.py
+++ b/test/test_gutterrendererchunk.py
@@ -3,7 +3,7 @@ from unittest import mock
 
 import pytest
 
-from meld.const import MODE_DELETE, MODE_INSERT, MODE_REPLACE
+from meld.const import ActionMode
 from meld.matchers.myers import DiffChunk
 
 
@@ -13,60 +13,59 @@ def make_chunk(chunk_type):
 
 @pytest.mark.parametrize("mode, editable, chunk, expected_action", [
     # Replace mode with replace chunks
-    (MODE_REPLACE, (True, True), make_chunk('replace'), MODE_REPLACE),
-    (MODE_REPLACE, (True, False), make_chunk('replace'), MODE_DELETE),
-    (MODE_REPLACE, (False, True), make_chunk('replace'), MODE_REPLACE),
-    (MODE_REPLACE, (False, False), make_chunk('replace'), None),
+    (ActionMode.Replace, (True, True), make_chunk('replace'), ActionMode.Replace),
+    (ActionMode.Replace, (True, False), make_chunk('replace'), ActionMode.Delete),
+    (ActionMode.Replace, (False, True), make_chunk('replace'), ActionMode.Replace),
+    (ActionMode.Replace, (False, False), make_chunk('replace'), None),
     # Replace mode with delete chunks
-    (MODE_REPLACE, (True, True), make_chunk('delete'), MODE_REPLACE),
-    (MODE_REPLACE, (True, False), make_chunk('delete'), MODE_DELETE),
-    (MODE_REPLACE, (False, True), make_chunk('delete'), MODE_REPLACE),
-    (MODE_REPLACE, (False, False), make_chunk('delete'), None),
+    (ActionMode.Replace, (True, True), make_chunk('delete'), ActionMode.Replace),
+    (ActionMode.Replace, (True, False), make_chunk('delete'), ActionMode.Delete),
+    (ActionMode.Replace, (False, True), make_chunk('delete'), ActionMode.Replace),
+    (ActionMode.Replace, (False, False), make_chunk('delete'), None),
     # Delete mode makes a slightly weird choice to remove non-delete
     # actions while in delete mode; insert mode makes the opposite
     # choice
     #
     # Delete mode with replace chunks
-    (MODE_DELETE, (True, True), make_chunk('replace'), MODE_DELETE),
-    (MODE_DELETE, (True, False), make_chunk('replace'), MODE_DELETE),
-    (MODE_DELETE, (False, True), make_chunk('replace'), None),
-    (MODE_DELETE, (False, False), make_chunk('replace'), None),
+    (ActionMode.Delete, (True, True), make_chunk('replace'), ActionMode.Delete),
+    (ActionMode.Delete, (True, False), make_chunk('replace'), ActionMode.Delete),
+    (ActionMode.Delete, (False, True), make_chunk('replace'), None),
+    (ActionMode.Delete, (False, False), make_chunk('replace'), None),
     # Delete mode with delete chunks
-    (MODE_DELETE, (True, True), make_chunk('delete'), MODE_DELETE),
-    (MODE_DELETE, (True, False), make_chunk('delete'), MODE_DELETE),
-    (MODE_DELETE, (False, True), make_chunk('delete'), None),
-    (MODE_DELETE, (False, False), make_chunk('delete'), None),
+    (ActionMode.Delete, (True, True), make_chunk('delete'), ActionMode.Delete),
+    (ActionMode.Delete, (True, False), make_chunk('delete'), ActionMode.Delete),
+    (ActionMode.Delete, (False, True), make_chunk('delete'), None),
+    (ActionMode.Delete, (False, False), make_chunk('delete'), None),
     # Insert mode with replace chunks
-    (MODE_INSERT, (True, True), make_chunk('replace'), MODE_INSERT),
-    (MODE_INSERT, (True, False), make_chunk('replace'), MODE_DELETE),
-    (MODE_INSERT, (False, True), make_chunk('replace'), MODE_INSERT),
-    (MODE_INSERT, (False, False), make_chunk('replace'), None),
+    (ActionMode.Insert, (True, True), make_chunk('replace'), ActionMode.Insert),
+    (ActionMode.Insert, (True, False), make_chunk('replace'), ActionMode.Delete),
+    (ActionMode.Insert, (False, True), make_chunk('replace'), ActionMode.Insert),
+    (ActionMode.Insert, (False, False), make_chunk('replace'), None),
     # Insert mode with delete chunks
-    (MODE_INSERT, (True, True), make_chunk('delete'), MODE_REPLACE),
-    (MODE_INSERT, (True, False), make_chunk('delete'), MODE_DELETE),
-    (MODE_INSERT, (False, True), make_chunk('delete'), MODE_REPLACE),
-    (MODE_INSERT, (False, False), make_chunk('delete'), None),
+    (ActionMode.Insert, (True, True), make_chunk('delete'), ActionMode.Replace),
+    (ActionMode.Insert, (True, False), make_chunk('delete'), ActionMode.Delete),
+    (ActionMode.Insert, (False, True), make_chunk('delete'), ActionMode.Replace),
+    (ActionMode.Insert, (False, False), make_chunk('delete'), None),
     # We should never have insert chunks here
-    (MODE_REPLACE, (True, True), make_chunk('insert'), None),
-    (MODE_REPLACE, (True, False), make_chunk('insert'), None),
-    (MODE_REPLACE, (False, True), make_chunk('insert'), None),
-    (MODE_REPLACE, (False, False), make_chunk('insert'), None),
+    (ActionMode.Replace, (True, True), make_chunk('insert'), None),
+    (ActionMode.Replace, (True, False), make_chunk('insert'), None),
+    (ActionMode.Replace, (False, True), make_chunk('insert'), None),
+    (ActionMode.Replace, (False, False), make_chunk('insert'), None),
 
     # TODO: Add tests for conflict chunks
 ])
 def test_classify_change_actions(mode, editable, chunk, expected_action):
 
-    import meld.gutterrendererchunk
-    from meld.gutterrendererchunk import GutterRendererChunkAction
+    from meld.actiongutter import ActionGutter
 
-    filediff = mock.MagicMock()
-    meld.gutterrendererchunk.meldsettings = mock.MagicMock(style_scheme=None)
-    GutterRendererChunkAction.on_setting_changed = mock.MagicMock()
-    renderer = GutterRendererChunkAction(
-        0, 1, mock.MagicMock(), filediff, None)
+    source_editable, target_editable = editable
 
-    renderer.mode = mode
-    renderer.views_editable = editable
-    action = renderer._classify_change_actions(chunk)
+    renderer = ActionGutter()
+    renderer._source_view = mock.Mock()
+    renderer._source_view.get_editable.return_value = source_editable
+    renderer._target_view = mock.Mock()
+    renderer._target_view.get_editable.return_value = target_editable
+    renderer.action_mode = mode
 
+    action = renderer._classify_change_actions(chunk)
     assert action == expected_action


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]