def test_options(self): """ Tests if it read the config file and return the config options for a given process """ class MockConfig: """ Mock Config class """ flag = None def __init__(self): self.name = None def sections(self): """ Mock sections methos """ if self.flag == 1: return [] return ["program:salt"] def items(self, name): """ Mock sections methos """ self.name = name return [("salt", "True")] with patch.object( supervisord, "_read_config", MagicMock(return_value=MockConfig()) ): MockConfig.flag = 1 self.assertRaises(CommandExecutionError, supervisord.options, "salt") MockConfig.flag = 0 self.assertDictEqual(supervisord.options("salt"), {"salt": True})
def test_options(self): ''' Tests if it read the config file and return the config options for a given process ''' class MockConfig(object): ''' Mock Config class ''' flag = None def __init__(self): self.name = None def sections(self): ''' Mock sections methos ''' if self.flag == 1: return [] return ['program:salt'] def items(self, name): ''' Mock sections methos ''' self.name = name return [('salt', 'True')] with patch.object(supervisord, '_read_config', MagicMock(return_value=MockConfig())): MockConfig.flag = 1 self.assertRaises(CommandExecutionError, supervisord.options, 'salt') MockConfig.flag = 0 self.assertDictEqual(supervisord.options('salt'), {'salt': True})