def test_generate_build_tasks_to_build_directory(self):
    'Test generate_build_tasks_to_build_directory queues up a\n        corresponding number of build tasks according to the given scenario.\n        '
    EXTENSIONS_DIRNAMES_TO_DIRPATHS = {'dev_dir': MOCK_EXTENSIONS_DEV_DIR, 'compiled_js_dir': MOCK_EXTENSIONS_COMPILED_JS_DIR, 'staging_dir': os.path.join(TEST_DIR, 'backend_prod_files', 'extensions', ''), 'out_dir': os.path.join(TEST_DIR, 'build', 'extensions', '')}
    file_hashes = build.get_file_hashes(MOCK_EXTENSIONS_DEV_DIR)
    compiled_js_file_hashes = build.get_file_hashes(MOCK_EXTENSIONS_COMPILED_JS_DIR)
    build_dir_tasks = collections.deque()
    build_all_files_tasks = build.generate_build_tasks_to_build_all_files_in_directory(MOCK_EXTENSIONS_DEV_DIR, EXTENSIONS_DIRNAMES_TO_DIRPATHS['out_dir'], file_hashes)
    build_all_files_tasks += build.generate_build_tasks_to_build_all_files_in_directory(MOCK_EXTENSIONS_COMPILED_JS_DIR, EXTENSIONS_DIRNAMES_TO_DIRPATHS['out_dir'], compiled_js_file_hashes)
    self.assertGreater(len(build_all_files_tasks), 0)
    self.assertEqual(len(build_dir_tasks), 0)
    build_dir_tasks += build.generate_build_tasks_to_build_directory(EXTENSIONS_DIRNAMES_TO_DIRPATHS, file_hashes)
    self.assertEqual(len(build_dir_tasks), len(build_all_files_tasks))
    build.safe_delete_directory_tree(TEST_DIR)
    build_dir_tasks.clear()
    build.ensure_directory_exists(EXTENSIONS_DIRNAMES_TO_DIRPATHS['staging_dir'])
    self.assertEqual(len(build_dir_tasks), 0)
    source_hashes = file_hashes
    source_hashes.update(compiled_js_file_hashes)
    build_dir_tasks += build.generate_build_tasks_to_build_directory(EXTENSIONS_DIRNAMES_TO_DIRPATHS, source_hashes)
    self.assertEqual(len(build_dir_tasks), len(build_all_files_tasks))
    build.safe_delete_directory_tree(TEST_DIR)
    build.ensure_directory_exists(EXTENSIONS_DIRNAMES_TO_DIRPATHS['staging_dir'])
    build._execute_tasks(build_dir_tasks)
    self.assertEqual(threading.active_count(), 1)
    build._execute_tasks(build.generate_copy_tasks_to_copy_from_source_to_target(EXTENSIONS_DIRNAMES_TO_DIRPATHS['staging_dir'], EXTENSIONS_DIRNAMES_TO_DIRPATHS['out_dir'], file_hashes))
    build_dir_tasks.clear()
    self.assertEqual(len(build_dir_tasks), 0)
    build_dir_tasks += build.generate_build_tasks_to_build_directory(EXTENSIONS_DIRNAMES_TO_DIRPATHS, build_dir_tasks)
    file_extensions_to_always_rebuild = ('.html', '.py')
    always_rebuilt_filepaths = build.get_filepaths_by_extensions(MOCK_EXTENSIONS_DEV_DIR, file_extensions_to_always_rebuild)
    self.assertGreater(len(always_rebuilt_filepaths), 0)
    self.assertEqual(len(build_dir_tasks), len(always_rebuilt_filepaths))
    build.safe_delete_directory_tree(TEST_DIR)
Test generate_build_tasks_to_build_directory queues up a
corresponding number of build tasks according to the given scenario.
def test_generate_build_tasks_to_build_directory(self):
    'Test generate_build_tasks_to_build_directory queues up a\n        corresponding number of build tasks according to the given scenario.\n        '
    EXTENSIONS_DIRNAMES_TO_DIRPATHS = {'dev_dir': MOCK_EXTENSIONS_DEV_DIR, 'compiled_js_dir': MOCK_EXTENSIONS_COMPILED_JS_DIR, 'staging_dir': os.path.join(TEST_DIR, 'backend_prod_files', 'extensions', ), 'out_dir': os.path.join(TEST_DIR, 'build', 'extensions', )}
    file_hashes = build.get_file_hashes(MOCK_EXTENSIONS_DEV_DIR)
    compiled_js_file_hashes = build.get_file_hashes(MOCK_EXTENSIONS_COMPILED_JS_DIR)
    build_dir_tasks = collections.deque()
    build_all_files_tasks = build.generate_build_tasks_to_build_all_files_in_directory(MOCK_EXTENSIONS_DEV_DIR, EXTENSIONS_DIRNAMES_TO_DIRPATHS['out_dir'], file_hashes)
    build_all_files_tasks += build.generate_build_tasks_to_build_all_files_in_directory(MOCK_EXTENSIONS_COMPILED_JS_DIR, EXTENSIONS_DIRNAMES_TO_DIRPATHS['out_dir'], compiled_js_file_hashes)
    self.assertGreater(len(build_all_files_tasks), 0)
    self.assertEqual(len(build_dir_tasks), 0)
    build_dir_tasks += build.generate_build_tasks_to_build_directory(EXTENSIONS_DIRNAMES_TO_DIRPATHS, file_hashes)
    self.assertEqual(len(build_dir_tasks), len(build_all_files_tasks))
    build.safe_delete_directory_tree(TEST_DIR)
    build_dir_tasks.clear()
    build.ensure_directory_exists(EXTENSIONS_DIRNAMES_TO_DIRPATHS['staging_dir'])
    self.assertEqual(len(build_dir_tasks), 0)
    source_hashes = file_hashes
    source_hashes.update(compiled_js_file_hashes)
    build_dir_tasks += build.generate_build_tasks_to_build_directory(EXTENSIONS_DIRNAMES_TO_DIRPATHS, source_hashes)
    self.assertEqual(len(build_dir_tasks), len(build_all_files_tasks))
    build.safe_delete_directory_tree(TEST_DIR)
    build.ensure_directory_exists(EXTENSIONS_DIRNAMES_TO_DIRPATHS['staging_dir'])
    build._execute_tasks(build_dir_tasks)
    self.assertEqual(threading.active_count(), 1)
    build._execute_tasks(build.generate_copy_tasks_to_copy_from_source_to_target(EXTENSIONS_DIRNAMES_TO_DIRPATHS['staging_dir'], EXTENSIONS_DIRNAMES_TO_DIRPATHS['out_dir'], file_hashes))
    build_dir_tasks.clear()
    self.assertEqual(len(build_dir_tasks), 0)
    build_dir_tasks += build.generate_build_tasks_to_build_directory(EXTENSIONS_DIRNAMES_TO_DIRPATHS, build_dir_tasks)
    file_extensions_to_always_rebuild = ('.html', '.py')
    always_rebuilt_filepaths = build.get_filepaths_by_extensions(MOCK_EXTENSIONS_DEV_DIR, file_extensions_to_always_rebuild)
    self.assertGreater(len(always_rebuilt_filepaths), 0)
    self.assertEqual(len(build_dir_tasks), len(always_rebuilt_filepaths))
    build.safe_delete_directory_tree(TEST_DIR)