Fixes https://github.com/redhat-performance/tuned/issues/241 Fedora is removing the unittest2 package: https://bugzilla.redhat.com/show_bug.cgi?id=1794222 tuned is not targeting Python 2.6: https://github.com/redhat-performance/tuned/issues/241#issuecomment-588320175 One thing not present in Python 2.7 is assertItemsEqual() -- renamed to assertCountEqual(). Related, mock was also listed as a requirement in the spec file, but all the imports are from unittest.mock, hence removed.
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
import unittest
|
|
from tuned.profiles import Unit
|
|
|
|
class UnitTestCase(unittest.TestCase):
|
|
|
|
def test_default_options(self):
|
|
unit = Unit("sample", {})
|
|
self.assertEqual(unit.name, "sample")
|
|
self.assertEqual(unit.type, "sample")
|
|
self.assertTrue(unit.enabled)
|
|
self.assertFalse(unit.replace)
|
|
self.assertDictEqual(unit.options, {})
|
|
|
|
def test_option_type(self):
|
|
unit = Unit("sample", {"type": "net"})
|
|
self.assertEqual(unit.type, "net")
|
|
|
|
def test_option_enabled(self):
|
|
unit = Unit("sample", {"enabled": False})
|
|
self.assertFalse(unit.enabled)
|
|
unit.enabled = True
|
|
self.assertTrue(unit.enabled)
|
|
|
|
def test_option_replace(self):
|
|
unit = Unit("sample", {"replace": True})
|
|
self.assertTrue(unit.replace)
|
|
|
|
def test_option_custom(self):
|
|
unit = Unit("sample", {"enabled": True, "type": "net", "custom": "value", "foo": "bar"})
|
|
self.assertDictEqual(unit.options, {"custom": "value", "foo": "bar"})
|
|
unit.options = {"hello": "world"}
|
|
self.assertDictEqual(unit.options, {"hello": "world"})
|
|
|
|
def test_parsing_options(self):
|
|
unit = Unit("sample", {"type": "net", "enabled": True, "replace": True, "other": "foo"})
|
|
self.assertEqual(unit.type, "net")
|