From 7aafbccb323ef87049f8c51aeafb11c6e8461334 Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Tue, 18 Apr 2017 11:53:28 +0200 Subject: [PATCH 1/3] profile units are OrderedDicts, not lists refs #35 --- tests/profiles/test_profile.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/profiles/test_profile.py b/tests/profiles/test_profile.py index 419fb6b..d474781 100644 --- a/tests/profiles/test_profile.py +++ b/tests/profiles/test_profile.py @@ -1,5 +1,6 @@ import unittest import tuned.profiles +import collections class MockProfile(tuned.profiles.profile.Profile): def _create_unit(self, name, config): @@ -17,14 +18,14 @@ class ProfileTestCase(unittest.TestCase): "storage" : { "type": "disk" }, }) - self.assertIs(type(profile.units), list) + self.assertIs(type(profile.units), collections.OrderedDict) self.assertEqual(len(profile.units), 2) self.assertListEqual(sorted(map(lambda (name, config): name, profile.units)), sorted(["network", "storage"])) def test_create_units_empty(self): profile = MockProfile("test", {"main":{}}) - self.assertIs(type(profile.units), list) + self.assertIs(type(profile.units), collections.OrderedDict) self.assertEqual(len(profile.units), 0) def test_sets_name(self): From 7f087627efc553d2b3bca4b1356d5a20984e59b7 Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Tue, 18 Apr 2017 12:15:54 +0200 Subject: [PATCH 2/3] move DeviceMatcher to hardware --- tests/{units => hardware}/__init__.py | 0 tests/{units => hardware}/test_device_matcher.py | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename tests/{units => hardware}/__init__.py (100%) rename tests/{units => hardware}/test_device_matcher.py (95%) diff --git a/tests/units/__init__.py b/tests/hardware/__init__.py similarity index 100% rename from tests/units/__init__.py rename to tests/hardware/__init__.py diff --git a/tests/units/test_device_matcher.py b/tests/hardware/test_device_matcher.py similarity index 95% rename from tests/units/test_device_matcher.py rename to tests/hardware/test_device_matcher.py index 14f18d5..d3e879f 100644 --- a/tests/units/test_device_matcher.py +++ b/tests/hardware/test_device_matcher.py @@ -1,5 +1,5 @@ import unittest -from tuned.units.device_matcher import DeviceMatcher +from tuned.hardware.device_matcher import DeviceMatcher class DeviceMatcherTestCase(unittest.TestCase): @classmethod From 24fad6bbeafe709962db453f712e7a87bd86efdd Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Tue, 18 Apr 2017 12:17:55 +0200 Subject: [PATCH 3/3] fix empty DeviceMatcher rules --- tuned/hardware/device_matcher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tuned/hardware/device_matcher.py b/tuned/hardware/device_matcher.py index bb3d7a8..8e78ea1 100644 --- a/tuned/hardware/device_matcher.py +++ b/tuned/hardware/device_matcher.py @@ -22,7 +22,7 @@ class DeviceMatcher(object): if isinstance(rules, basestring): rules = re.split(r"\s|,\s*", rules) - positive_rules = filter(lambda rule: not rule.startswith("!"), rules) + positive_rules = filter(lambda rule: not rule.startswith("!") and not rule.strip() == '', rules) negative_rules = [rule[1:] for rule in rules if rule not in positive_rules] if len(positive_rules) == 0: