def test_notifier_type_missing(self): with open('%s/backuppy.json' % CONFIGURATION_PATH) as f: configuration = json.load(f) del configuration['notifications'][0]['type'] with NamedTemporaryFile(mode='w+t') as f: json.dump(configuration, f) with self.assertRaises(ValueError): from_configuration_data(f.name, configuration)
def test_interactive_non_boolean(self): with open('%s/backuppy.json' % CONFIGURATION_PATH) as f: configuration = json.load(f) configuration['interactive'] = 666 with NamedTemporaryFile(mode='w+t') as f: json.dump(configuration, f) with self.assertRaises(ValueError): from_configuration_data(f.name, configuration)
def test_logging(self, m): with open('%s/backuppy.json' % CONFIGURATION_PATH) as f: configuration_data = json.load(f) configuration_data['logging'] = { 'version': 1, 'handlers': { __name__: { 'class': 'logging.FileHandler', 'filename': '/tmp/foo', }, }, 'loggers': { 'backuppy': { 'handlers': [__name__], }, }, } from_configuration_data(f.name, configuration_data) m.assert_called_with(configuration_data['logging'])
def test_minimal(self): with open('%s/backuppy-minimal.json' % CONFIGURATION_PATH) as f: configuration = from_configuration_data(f.name, json.load(f)) self.assertIsInstance(configuration, Configuration)