コード例 #1
0
    def test_config_registers_fetcher_callback(self):
        c = Config()
        called = False

        def callback():
            nonlocal called
            called = True
        c.register_fetcher_callback(callback)
        data = {'type': 'LocalFetcher', 'src': 'somecontext'}
        c.load_fetcher(data)
        self.assertTrue(called)
コード例 #2
0
    def test_config_callback_on_data_config(self):
        c = Config(data=example_mixed)
        called_fetcher = False

        def callback_fetcher():
            nonlocal called_fetcher
            called_fetcher = True

        called_publisher = False

        def callback_publisher():
            nonlocal called_publisher
            called_publisher = True
        c.register_fetcher_callback(callback_fetcher)
        self.assertTrue(called_fetcher)
        c.register_fetcher_callback(callback_publisher)
        self.assertTrue(called_publisher)
コード例 #3
0
    def test_config_callback_on_file_config(self):
        c = Config(config_file='test/resources/run1.json')
        called_fetcher = False

        def callback_fetcher():
            nonlocal called_fetcher
            called_fetcher = True

        called_publisher = False

        def callback_publisher():
            nonlocal called_publisher
            called_publisher = True
        c.register_fetcher_callback(callback_fetcher)
        self.assertTrue(called_fetcher)
        c.register_fetcher_callback(callback_publisher)
        self.assertTrue(called_publisher)