Beispiel #1
0
def test_process_source_progress():
    with ThreadPoolExecutor(2) as executor:
        source = Source(path.join(here, 'files/1234'))
        sink = Mock()
        progress = Mock(spec=Progress)

        with source:
            process_source(executor, source, [sink], block_size=3, progress=progress)

        progress.set.assert_has_calls([call(3), call(4)])
Beispiel #2
0
def test_process_source():
    with ThreadPoolExecutor(2) as executor:
        source = Source(path.join(here, 'files/empty'))
        sink = Mock()
        with source:
            process_source(executor, source, [sink])

        assert not sink.called

        source = Source(path.join(here, 'files/1234'))
        with source:
            process_source(executor, source, [sink])

        sink.process.assert_called_once_with(b'\x01\x02\x03\x04')

        sink.reset_mock()
        with source:
            process_source(executor, source, [sink], block_size=1)

        assert sink.process.call_count == 4