def test_full_instantiation(self): # one of each class DummyGit(Repo): schema = Schema({}, extra=ALLOW_EXTRA) def __init__(self, type, name): super(DummyGit, self).__init__(type, name) def actions(self): pass def path_for(self, source): pass class DummyPath(Source): schema = Schema({}, extra=ALLOW_EXTRA) def __init__(self, type, name, repo): super(DummyPath, self).__init__(type, name, repo) def process(self, path): pass class DummyEmail(Notifier): schema = Schema({}, extra=ALLOW_EXTRA) def __init__(self, type, name): super(DummyEmail, self).__init__(type, name, level=0, fmt='f', datefmt='d') def start(self): pass def finish(self): pass plugins = Plugins() plugins.register('repo', 'git', DummyGit) plugins.register('source', 'path', DummyPath) plugins.register('notification', 'email', DummyEmail) source = open(self.dir.write('test.yaml', """ repos: - name: config type: git sources: - path: /some/path notifications: - email: [email protected] """)) config = Config.load(source, plugins) compare( C(Config, repos=dict(config=C(DummyGit, type='git', name='config')), sources=[C(DummyPath, type='path', repo='config', name='/some/path')], notifications=[ C(DummyEmail, type='email', name='*****@*****.**', level=0, fmt='f', datefmt='d') ]), config )
def test_defaults_instantiate(self): plugins = Plugins.load() git = plugins.get('repo', 'git') paths = plugins.get('source', 'paths') stream = plugins.get('notification', 'stream') file_path = self.dir.write('test.conf', 'conf content') source = open(self.dir.write('test.yaml', """ sources: - paths: - {} """.format(file_path))) config = Config.load(source, plugins) compare( C(Config, repos=dict(config=C(git, strict=False, **default_repo_config)), sources=[C(paths, type='paths', repo='config', name=None, source_paths=[file_path])], notifications=[ C(stream, strict=False, **default_notifications_config) ]), config )