Пример #1
0
    def test_handle_processed_files__not_finished_at_start(self):
        files = collections.OrderedDict()
        files['1'] = memc_load.FileInfo('1')
        files['2'] = memc_load.FileInfo('2')
        files['3'] = memc_load.FileInfo('3')

        files['1'].set_run_status()
        files['1'].processed = 1
        files['2'].set_finished_status()
        files['2'].processed = 1
        files['3'].set_run_status()

        memc_load.handle_processed_files(files)
        self.assertEqual(len(files), 3)
Пример #2
0
    def test_start_file_readers__little_avail_threads(self):
        called_count = 0

        def stub_func(*args, **kwargs):
            nonlocal called_count
            called_count += 1

        avail_threads = 2
        files = {x: memc_load.FileInfo('') for x in range(avail_threads+2)}
        memc_load.start_file_readers(stub_func, avail_threads, files, {}, queue.Queue())
        time.sleep(0.5)

        self.assertEqual(avail_threads, called_count)
Пример #3
0
    def test_start_files_readers__files_with_wait_status(self):
        called_count = 0

        def stub_func(*args, **kwargs):
            nonlocal called_count
            called_count += 1

        avail_threads = 5
        self.assertTrue(avail_threads > 3)

        files = {x: memc_load.FileInfo('') for x in range(avail_threads - 2)}
        files[0].set_run_status()
        files[1].set_run_status()
        memc_load.start_file_readers(stub_func, avail_threads, files, {}, queue.Queue())
        time.sleep(0.5)

        self.assertEqual(len(files)-2, called_count)