]> Frank Brehm's Git Trees - pixelpark/admin-tools.git/commitdiff
Testing
authorFrank Brehm <frank.brehm@pixelpark.com>
Fri, 7 Apr 2017 15:13:24 +0000 (17:13 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Fri, 7 Apr 2017 15:13:24 +0000 (17:13 +0200)
pp_lib/differ.py
test/files/base.ini [new file with mode: 0644]
test/files/blanklines.ini [new file with mode: 0644]
test/files/clone.ini [new file with mode: 0644]
test/files/comments.ini [new file with mode: 0644]
test/files/ignorecase.ini [new file with mode: 0644]
test/files/withespace.ini [new file with mode: 0644]
test/general.py
test/test_differ.py

index 98609e8e8eb9d9d511b5e6e582e7902386400066..085e22acd40e639c38c84f461dcc74e17413442f 100644 (file)
@@ -64,6 +64,9 @@ class ConfigDiffer(Differ):
         self.ignore_comment = ignore_comment
         self.case_insensitive = case_insensitive
 
+        if self.ignore_comment:
+            self.ignore_empty = True
+
         if comment_chars:
             if isinstance(comment_chars, (list, set, tuple)):
                 for char in comment_chars:
diff --git a/test/files/base.ini b/test/files/base.ini
new file mode 100644 (file)
index 0000000..f0096f0
--- /dev/null
@@ -0,0 +1,62 @@
+[core]
+; some core components
+s0_active_plugins = core;composite;opengl;compiztoolbox;copytex;decor;imgpng;cube;gnomecompat;regex;rotate;move;resize;grid;commands;staticswitcher;animation;expo;wobbly;
+s0_hsize = 4
+s0_focus_prevention_level = 1
+s0_focus_prevention_match = !(class=Polkit-gnome-authentication-agent-1) & !(class=MintMenu.py)
+
+[gnomecompat]
+# Gnome compatibility
+s0_command_screenshot = mate-screenshot
+s0_command_window_screenshot = mate-screenshot --window
+s0_command_terminal = mate-terminal
+
+[crashhandler]
+s0_wm_cmd = marco --replace
+
+[grid]
+s0_top_left_corner_action = 7
+s0_top_right_corner_action = 9
+s0_bottom_left_corner_action = 1
+s0_bottom_right_corner_action = 3
+s0_bottom_edge_action = 2
+s0_top_edge_action = 8
+s0_outline_color = #84fb009f
+s0_fill_color = #74fb004f
+
+[resize]
+# Colors on resizing
+s0_border_color = #7dfb009f
+s0_fill_color = #8afb0019
+
+[expo]
+s0_selected_color = #000000ff
+s0_reflection = true
+s0_expo_key = <Control><Alt>Up
+
+[wall]
+s0_up_key = Disabled
+s0_down_key = Disabled
+
+[animation]
+; Animation effects
+s0_unminimize_effects = 
+s0_unminimize_durations = 
+s0_unminimize_matches = 
+s0_unminimize_options = 
+s0_unminimize_random_effects = 
+
+[cube]
+s0_top_color = #3c3c3cff
+s0_bottom_color = #3c3c3cff
+s0_skydome = true
+s0_skydome_gradient_start_color = #000000ff
+s0_skydome_gradient_end_color = #727272ff
+
+[staticswitcher]
+s0_prev-all-key = <Shift><Alt>Tab
+s0_next-all-key = <Alt>Tab
+
+[td]
+
+
diff --git a/test/files/blanklines.ini b/test/files/blanklines.ini
new file mode 100644 (file)
index 0000000..74fb8e6
--- /dev/null
@@ -0,0 +1,71 @@
+[core]
+; some core components
+
+s0_active_plugins = core;composite;opengl;compiztoolbox;copytex;decor;imgpng;cube;gnomecompat;regex;rotate;move;resize;grid;commands;staticswitcher;animation;expo;wobbly;
+s0_hsize = 4
+s0_focus_prevention_level = 1
+s0_focus_prevention_match = !(class=Polkit-gnome-authentication-agent-1) & !(class=MintMenu.py)
+
+[gnomecompat]
+# Gnome compatibility
+
+s0_command_screenshot = mate-screenshot
+s0_command_window_screenshot = mate-screenshot --window
+s0_command_terminal = mate-terminal
+
+[crashhandler]
+
+s0_wm_cmd = marco --replace
+
+[grid]
+
+s0_top_left_corner_action = 7
+s0_top_right_corner_action = 9
+s0_bottom_left_corner_action = 1
+s0_bottom_right_corner_action = 3
+s0_bottom_edge_action = 2
+s0_top_edge_action = 8
+s0_outline_color = #84fb009f
+s0_fill_color = #74fb004f
+
+[resize]
+# Colors on resizing
+
+s0_border_color = #7dfb009f
+s0_fill_color = #8afb0019
+
+[expo]
+
+s0_selected_color = #000000ff
+s0_reflection = true
+s0_expo_key = <Control><Alt>Up
+
+[wall]
+
+s0_up_key = Disabled
+s0_down_key = Disabled
+
+[animation]
+; Animation effects
+
+s0_unminimize_effects = 
+s0_unminimize_durations = 
+s0_unminimize_matches = 
+s0_unminimize_options = 
+s0_unminimize_random_effects = 
+
+[cube]
+
+s0_top_color = #3c3c3cff
+s0_bottom_color = #3c3c3cff
+s0_skydome = true
+s0_skydome_gradient_start_color = #000000ff
+s0_skydome_gradient_end_color = #727272ff
+
+[staticswitcher]
+
+s0_prev-all-key = <Shift><Alt>Tab
+s0_next-all-key = <Alt>Tab
+
+[td]
+
diff --git a/test/files/clone.ini b/test/files/clone.ini
new file mode 100644 (file)
index 0000000..f0096f0
--- /dev/null
@@ -0,0 +1,62 @@
+[core]
+; some core components
+s0_active_plugins = core;composite;opengl;compiztoolbox;copytex;decor;imgpng;cube;gnomecompat;regex;rotate;move;resize;grid;commands;staticswitcher;animation;expo;wobbly;
+s0_hsize = 4
+s0_focus_prevention_level = 1
+s0_focus_prevention_match = !(class=Polkit-gnome-authentication-agent-1) & !(class=MintMenu.py)
+
+[gnomecompat]
+# Gnome compatibility
+s0_command_screenshot = mate-screenshot
+s0_command_window_screenshot = mate-screenshot --window
+s0_command_terminal = mate-terminal
+
+[crashhandler]
+s0_wm_cmd = marco --replace
+
+[grid]
+s0_top_left_corner_action = 7
+s0_top_right_corner_action = 9
+s0_bottom_left_corner_action = 1
+s0_bottom_right_corner_action = 3
+s0_bottom_edge_action = 2
+s0_top_edge_action = 8
+s0_outline_color = #84fb009f
+s0_fill_color = #74fb004f
+
+[resize]
+# Colors on resizing
+s0_border_color = #7dfb009f
+s0_fill_color = #8afb0019
+
+[expo]
+s0_selected_color = #000000ff
+s0_reflection = true
+s0_expo_key = <Control><Alt>Up
+
+[wall]
+s0_up_key = Disabled
+s0_down_key = Disabled
+
+[animation]
+; Animation effects
+s0_unminimize_effects = 
+s0_unminimize_durations = 
+s0_unminimize_matches = 
+s0_unminimize_options = 
+s0_unminimize_random_effects = 
+
+[cube]
+s0_top_color = #3c3c3cff
+s0_bottom_color = #3c3c3cff
+s0_skydome = true
+s0_skydome_gradient_start_color = #000000ff
+s0_skydome_gradient_end_color = #727272ff
+
+[staticswitcher]
+s0_prev-all-key = <Shift><Alt>Tab
+s0_next-all-key = <Alt>Tab
+
+[td]
+
+
diff --git a/test/files/comments.ini b/test/files/comments.ini
new file mode 100644 (file)
index 0000000..aaf51c7
--- /dev/null
@@ -0,0 +1,62 @@
+[core]
+s0_active_plugins = core;composite;opengl;compiztoolbox;copytex;decor;imgpng;cube;gnomecompat;regex;rotate;move;resize;grid;commands;staticswitcher;animation;expo;wobbly;
+s0_hsize = 4
+s0_focus_prevention_level = 1
+s0_focus_prevention_match = !(class=Polkit-gnome-authentication-agent-1) & !(class=MintMenu.py)
+
+[gnomecompat]
+# Gnome compatibility
+s0_command_screenshot = mate-screenshot
+s0_command_window_screenshot = mate-screenshot --window
+s0_command_terminal = mate-terminal
+
+[crashhandler]
+# crashhandler stuff
+s0_wm_cmd = marco --replace
+
+[grid]
+s0_top_left_corner_action = 7
+s0_top_right_corner_action = 9
+s0_bottom_left_corner_action = 1
+s0_bottom_right_corner_action = 3
+s0_bottom_edge_action = 2
+s0_top_edge_action = 8
+s0_outline_color = #84fb009f
+s0_fill_color = #74fb004f
+
+[resize]
+; Colors on resizing
+s0_border_color = #7dfb009f
+s0_fill_color = #8afb0019
+
+[expo]
+s0_selected_color = #000000ff
+s0_reflection = true
+s0_expo_key = <Control><Alt>Up
+
+[wall]
+s0_up_key = Disabled
+s0_down_key = Disabled
+
+[animation]
+; Animation effects
+s0_unminimize_effects = 
+s0_unminimize_durations = 
+s0_unminimize_matches = 
+s0_unminimize_options = 
+s0_unminimize_random_effects = 
+
+[cube]
+s0_top_color = #3c3c3cff
+s0_bottom_color = #3c3c3cff
+s0_skydome = true
+s0_skydome_gradient_start_color = #000000ff
+s0_skydome_gradient_end_color = #727272ff
+
+[staticswitcher]
+s0_prev-all-key = <Shift><Alt>Tab
+s0_next-all-key = <Alt>Tab
+
+[td]
+
+# vim: et filetype=dosini
diff --git a/test/files/ignorecase.ini b/test/files/ignorecase.ini
new file mode 100644 (file)
index 0000000..ae21c11
--- /dev/null
@@ -0,0 +1,62 @@
+[core]
+; some core components
+s0_active_plugins = core;composite;opengl;compiztoolbox;copytex;decor;imgpng;cube;gnomecompat;regex;rotate;move;resize;grid;commands;staticswitcher;animation;expo;wobbly;
+s0_hsize = 4
+s0_focus_prevention_level = 1
+s0_focus_prevention_match = !(class=Polkit-gnome-authentication-agent-1) & !(class=MintMenu.py)
+
+[gnomecompat]
+# Gnome compatibility
+s0_command_screenshot = mate-screenshot
+s0_command_window_screenshot = mate-screenshot --window
+s0_command_terminal = mate-terminal
+
+[crashhandler]
+s0_wm_cmd = marco --replace
+
+[grid]
+s0_top_left_corner_action = 7
+s0_top_right_corner_action = 9
+s0_bottom_left_corner_action = 1
+s0_bottom_right_corner_action = 3
+s0_bottom_edge_action = 2
+s0_top_edge_action = 8
+s0_outline_color = #84fb009f
+s0_fill_color = #74fb004f
+
+[resize]
+# colors on resizing
+s0_border_color = #7dfb009f
+s0_fill_color = #8afb0019
+
+[expo]
+s0_selected_color = #000000ff
+s0_reflection = true
+s0_expo_key = <Control><Alt>Up
+
+[wall]
+s0_up_key = Disabled
+s0_down_key = Disabled
+
+[animation]
+; animation effects
+s0_unminimize_effects = 
+s0_unminimize_durations = 
+s0_unminimize_matches = 
+s0_unminimize_options = 
+s0_unminimize_random_effects = 
+
+[cube]
+s0_top_color = #3c3c3cff
+s0_bottom_color = #3c3c3cff
+s0_skydome = true
+s0_skydome_gradient_start_color = #000000ff
+s0_skydome_gradient_end_color = #727272ff
+
+[staticswitcher]
+s0_prev-all-key = <shift><alt>tab
+s0_next-all-key = <ALT>TAB
+
+[td]
+
+
diff --git a/test/files/withespace.ini b/test/files/withespace.ini
new file mode 100644 (file)
index 0000000..915f055
--- /dev/null
@@ -0,0 +1,62 @@
+[core]
+; some core components
+s0_active_plugins = core;composite;opengl;compiztoolbox;copytex;decor;imgpng;cube;gnomecompat;regex;rotate;move;resize;grid;commands;staticswitcher;animation;expo;wobbly;
+s0_hsize = 4
+s0_focus_prevention_level = 1
+s0_focus_prevention_match = !(class=Polkit-gnome-authentication-agent-1) & !(class=MintMenu.py)
+
+[gnomecompat]
+# Gnome compatibility
+s0_command_screenshot = mate-screenshot
+s0_command_window_screenshot = mate-screenshot --window
+s0_command_terminal = mate-terminal
+
+[crashhandler]
+s0_wm_cmd = marco --replace
+
+[grid]
+s0_top_left_corner_action     = 7
+s0_top_right_corner_action    = 9
+s0_bottom_left_corner_action  = 1
+s0_bottom_right_corner_action = 3
+s0_bottom_edge_action         = 2
+s0_top_edge_action            = 8
+s0_outline_color              = #84fb009f
+s0_fill_color                 = #74fb004f
+
+[resize]
+# Colors on resizing
+s0_border_color = #7dfb009f
+s0_fill_color   = #8afb0019
+
+[expo]
+s0_selected_color = #000000ff
+s0_reflection     = true
+s0_expo_key       = <Control><Alt>Up
+
+[wall]
+s0_up_key   = Disabled
+s0_down_key = Disabled
+
+[animation]
+; Animation effects
+s0_unminimize_effects = 
+s0_unminimize_durations = 
+s0_unminimize_matches = 
+s0_unminimize_options = 
+s0_unminimize_random_effects = 
+
+[cube]
+s0_top_color = #3c3c3cff
+s0_bottom_color = #3c3c3cff
+s0_skydome = true
+s0_skydome_gradient_start_color = #000000ff
+s0_skydome_gradient_end_color = #727272ff
+
+[staticswitcher]
+s0_prev-all-key = <Shift><Alt>Tab
+s0_next-all-key = <Alt>Tab
+
+[td]
+
+
index 8a87f10e51800f8e49bd18d95f53ab115cf183bd..3d58dbeb293bf628c4052b3b49ecda3f7c2612eb 100644 (file)
@@ -83,6 +83,8 @@ class AdminToolsTestcase(unittest.TestCase):
 
         super(AdminToolsTestcase, self).__init__(methodName)
 
+        self.test_dir = os.path.abspath(os.path.dirname(__file__))
+
     # -------------------------------------------------------------------------
     @property
     def verbose(self):
index cf31589aa50059d881c1df7a85cd4d396b5afdc8..d1259c4bd3540d8057928f165bde5e14318fb0c0 100755 (executable)
@@ -12,12 +12,15 @@ import os
 import sys
 import logging
 import locale
+import re
 
 try:
     import unittest2 as unittest
 except ImportError:
     import unittest
 
+import six
+
 from pb_base.common import pp
 from pb_base.common import bytes2human
 
@@ -40,10 +43,39 @@ class ConfigDifferTest(AdminToolsTestcase):
     def setUp(self):
         self.appname = APPNAME
 
+        self.files_dir = os.path.join(self.test_dir, 'files')
+
+        self.cfg_base = os.path.join(self.files_dir, 'base.ini')
+        self.cfg_clone = os.path.join(self.files_dir, 'clone.ini')
+        self.cfg_blanklines = os.path.join(self.files_dir, 'blanklines.ini')
+        self.cfg_withespace = os.path.join(self.files_dir, 'withespace.ini')
+        self.cfg_comments = os.path.join(self.files_dir, 'comments.ini')
+        self.cfg_ignorecase = os.path.join(self.files_dir, 'ignorecase.ini')
+
+        self.re_eol = re.compile('(?:\r|\r?\n)$')
+
     # -------------------------------------------------------------------------
     def tearDown(self):
         pass
 
+    # -------------------------------------------------------------------------
+    def read_file(self, filename, strip_eol=False)):
+
+        lines = []
+
+        open_args = {}
+        if six.PY3:
+            open_args = {
+                'encoding': 'utf-8',
+                'errors': 'surrogateescape',
+            }
+
+        with open(filename, 'r', **open_args) as fh:
+            for line in fh.readlines():
+                if strip_eol:
+                    lines.append(self.re_eol.sub(line))
+                else:
+                    lines.append(line)
 
     # -------------------------------------------------------------------------
     def test_import(self):
@@ -123,6 +155,13 @@ class ConfigDifferTest(AdminToolsTestcase):
 
             self.assertEqual(result, expected)
 
+    # -------------------------------------------------------------------------
+    def test_compare_equal(self):
+
+        LOG.info("Testing execution of compare on equal string lists ...")
+
+        list_a = 
+
 
 # =============================================================================