def test_process_html(self):
    'Test process_html removes whitespaces and adds hash to filepaths.'
    BASE_HTML_SOURCE_PATH = os.path.join(MOCK_TEMPLATES_DEV_DIR, 'base.html')
    BASE_JS_RELATIVE_PATH = os.path.join('pages', 'Base.js')
    BASE_JS_SOURCE_PATH = os.path.join(MOCK_TEMPLATES_COMPILED_JS_DIR, BASE_JS_RELATIVE_PATH)
    build._ensure_files_exist([BASE_HTML_SOURCE_PATH, BASE_JS_SOURCE_PATH])
    minified_html_file_stream = StringIO.StringIO()
    with self.swap(build, 'FILE_EXTENSIONS_TO_IGNORE', ('.html',)):
        file_hashes = build.get_file_hashes(MOCK_TEMPLATES_DEV_DIR)
        file_hashes.update(build.get_file_hashes(MOCK_TEMPLATES_COMPILED_JS_DIR))
    with open(BASE_HTML_SOURCE_PATH, 'r') as source_base_file:
        source_base_file_content = source_base_file.read()
        self.assertRegexpMatches(source_base_file_content, '\\s{2,}', msg=('No white spaces detected in %s unexpectedly' % BASE_HTML_SOURCE_PATH))
        self.assertIn(BASE_JS_RELATIVE_PATH, source_base_file_content)
    with open(BASE_HTML_SOURCE_PATH, 'r') as source_base_file:
        build.process_html(source_base_file, minified_html_file_stream, file_hashes)
    minified_html_file_content = minified_html_file_stream.getvalue()
    self.assertNotRegexpMatches(minified_html_file_content, '\\s{2,}', msg=('All white spaces must be removed from %s' % BASE_HTML_SOURCE_PATH))
    final_filename = build._insert_hash(BASE_JS_RELATIVE_PATH, file_hashes[BASE_JS_RELATIVE_PATH])
    self.assertIn(final_filename, minified_html_file_content)
Test process_html removes whitespaces and adds hash to filepaths.
def test_process_html(self):
    
    BASE_HTML_SOURCE_PATH = os.path.join(MOCK_TEMPLATES_DEV_DIR, 'base.html')
    BASE_JS_RELATIVE_PATH = os.path.join('pages', 'Base.js')
    BASE_JS_SOURCE_PATH = os.path.join(MOCK_TEMPLATES_COMPILED_JS_DIR, BASE_JS_RELATIVE_PATH)
    build._ensure_files_exist([BASE_HTML_SOURCE_PATH, BASE_JS_SOURCE_PATH])
    minified_html_file_stream = StringIO.StringIO()
    with self.swap(build, 'FILE_EXTENSIONS_TO_IGNORE', ('.html',)):
        file_hashes = build.get_file_hashes(MOCK_TEMPLATES_DEV_DIR)
        file_hashes.update(build.get_file_hashes(MOCK_TEMPLATES_COMPILED_JS_DIR))
    with open(BASE_HTML_SOURCE_PATH, 'r') as source_base_file:
        source_base_file_content = source_base_file.read()
        self.assertRegexpMatches(source_base_file_content, '\\s{2,}', msg=('No white spaces detected in %s unexpectedly' % BASE_HTML_SOURCE_PATH))
        self.assertIn(BASE_JS_RELATIVE_PATH, source_base_file_content)
    with open(BASE_HTML_SOURCE_PATH, 'r') as source_base_file:
        build.process_html(source_base_file, minified_html_file_stream, file_hashes)
    minified_html_file_content = minified_html_file_stream.getvalue()
    self.assertNotRegexpMatches(minified_html_file_content, '\\s{2,}', msg=('All white spaces must be removed from %s' % BASE_HTML_SOURCE_PATH))
    final_filename = build._insert_hash(BASE_JS_RELATIVE_PATH, file_hashes[BASE_JS_RELATIVE_PATH])
    self.assertIn(final_filename, minified_html_file_content)