diff --git a/tests/css_validator_w3c.py b/tests/css_validator_w3c.py index 83fda697..f80904da 100644 --- a/tests/css_validator_w3c.py +++ b/tests/css_validator_w3c.py @@ -46,7 +46,8 @@ def run_test(global_translation, url): 'style_element': [], 'style_attribute': [], 'style_files': [] - } + }, + 'sources': [] } for html_entry in data['htmls']: @@ -59,6 +60,14 @@ def run_test(global_translation, url): rating += tmp_rating all_link_resources.extend(tmp_all_link_resources) + for resource_url in all_link_resources: + for entry in data['all']: + if resource_url == entry['url']: + result_dict['sources'].append({ + 'url': resource_url, + 'index': entry['index'] + }) + # 4 Check if website inlcuded css files in other ways for link_resource in all_link_resources: data_resource_info_to_remove = None @@ -123,8 +132,10 @@ def handle_html_markup_entry(entry, global_translation, url, local_translation, local_translation, f'- `style=""` in: {name}') - # 2.3 GET ERRORS FROM SERVICE - # 2.4 CALCULATE SCORE + if 'has_style_elements' in result_dict or\ + 'has_style_attributes' in result_dict: + all_link_resources.append(req_url) + # 3 FIND ALL (rel=\"stylesheet\") (link_resources, errors) = get_errors_for_link_tags(html, url) if len(link_resources) > 0: diff --git a/tests/w3c_base.py b/tests/w3c_base.py index 2e458052..630344f3 100644 --- a/tests/w3c_base.py +++ b/tests/w3c_base.py @@ -151,6 +151,7 @@ def identify_files(filename): """ data = { + 'all': [], 'htmls': [], 'elements': [], 'attributes': [], @@ -187,22 +188,26 @@ def identify_files(filename): True, timedelta(minutes=get_config('general.cache.max-age'))): set_cache_file(req_url, res['content']['text'], True) - data['htmls'].append({ + obj = { 'url': req_url, 'content': res['content']['text'], 'index': req_index - }) + } + data['all'].append(obj) + data['htmls'].append(obj) elif 'css' in res['content']['mimeType']: if not has_cache_file( req_url, True, timedelta(minutes=get_config('general.cache.max-age'))): set_cache_file(req_url, res['content']['text'], True) - data['resources'].append({ + obj = { 'url': req_url, 'content': res['content']['text'], 'index': req_index - }) + } + data['all'].append(obj) + data['resources'].append(obj) req_index += 1 return data