-
Notifications
You must be signed in to change notification settings - Fork 169
/
test_unit.py
36 lines (29 loc) · 1.14 KB
/
test_unit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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")