3 from __future__ import absolute_import, print_function
9 import arvnodeman.config as nmconfig
11 class NodeManagerConfigTestCase(unittest.TestCase):
15 shutdown_windows = 52, 6, 2
32 def load_config(self, config=None, config_str=None):
34 config = nmconfig.NodeManagerConfig()
35 if config_str is None:
36 config_str = self.TEST_CONFIG
37 with io.StringIO(config_str) as config_fp:
38 config.readfp(config_fp)
41 def test_seeded_defaults(self):
42 config = nmconfig.NodeManagerConfig()
43 sec_names = set(config.sections())
44 self.assertIn('Arvados', sec_names)
45 self.assertIn('Daemon', sec_names)
46 self.assertFalse(any(name.startswith('Size ') for name in sec_names))
48 def test_list_sizes(self):
49 config = self.load_config()
50 client = config.new_cloud_client()
51 sizes = config.node_sizes(client.list_sizes())
52 self.assertEqual(1, len(sizes))
53 size, kwargs = sizes[0]
54 self.assertEqual('Small', size.name)
55 self.assertEqual(1, kwargs['cores'])
57 def test_shutdown_windows(self):
58 config = self.load_config()
59 self.assertEqual([52, 6, 2], config.shutdown_windows())
61 def test_log_levels(self):
62 config = self.load_config()
63 self.assertEqual({'level': logging.DEBUG,
64 'testlogger': logging.INFO},