コード例 #1
0
ファイル: __init__.py プロジェクト: qdamian/dissect
    def __init__(self, base_path, callback):
        self.async_publisher = AsyncPublisher(callback)
        self.model = ObservableModel(self.async_publisher)

        entity_id_generator = EntityIdGenerator(base_path)
        modeling_orchestrator = Orchestrator(base_path, self.model)
        self.dynamic_modeling_driver = DynamicModelingDriver(self,
                                                     entity_id_generator,
                                                     modeling_orchestrator)
コード例 #2
0
    def test_it_invokes_the_callback_for_two_entities(self):
        # Given
        callback = Mock()
        fake_class = fake("Class_")
        fake_function = fake("Function")
        async_publisher = AsyncPublisher(callback)
        async_publisher.start()

        # When
        async_publisher.on_entity(fake_class)
        async_publisher.on_entity(fake_function)
        async_publisher.stop()

        # Then
        callback.assert_has_calls([call(fake_class), call(fake_function)])
コード例 #3
0
    def test_it_invokes_the_callback_for_one_entity(self):
        # Given
        callback = Mock()
        fake_entity = fake("Function")
        async_publisher = AsyncPublisher(callback)
        async_publisher.start()

        # When
        async_publisher.on_entity(fake_entity)
        async_publisher.stop()

        # Then
        callback.assert_called_once_with(fake_entity)
コード例 #4
0
    def test_on_entity_returns_before_the_callback_completes(self):
        # Given
        finish = threading.Event()
        callback = Mock()
        callback.side_effect = lambda entity: finish.wait()
        fake_entity = fake("Function")
        async_publisher = AsyncPublisher(callback)
        async_publisher.start()

        # When
        async_publisher.on_entity(fake_entity)
        finish.set()

        # Then
        async_publisher.stop()