From cb553b5f7ef0660b634987d8c44899934e62e63d Mon Sep 17 00:00:00 2001 From: pablo Date: Tue, 29 Dec 2020 20:42:21 +0100 Subject: [PATCH] Minor fixes in parsing utils. --- core/parsing_utils.py | 8 ++++++++ tests/parsing_utils_test.py | 1 + 2 files changed, 9 insertions(+) diff --git a/core/parsing_utils.py b/core/parsing_utils.py index 0cd7259..6b466f1 100644 --- a/core/parsing_utils.py +++ b/core/parsing_utils.py @@ -498,6 +498,14 @@ class ParsingFlow: for instruction in self._instructions: instruction.scrape(soup).validate() + @property + def field_values(self) -> Dict: + """ + Return the value for all fields, or None. + :return: a dict with the field names and values + """ + return {field.field_name: field.value for field in self._instructions} + @property def all_found_fields_are_valid(self) -> bool: """ diff --git a/tests/parsing_utils_test.py b/tests/parsing_utils_test.py index 533b4ba..a0a286a 100644 --- a/tests/parsing_utils_test.py +++ b/tests/parsing_utils_test.py @@ -2678,6 +2678,7 @@ def test_parsing_flow_works_for_ad_html(real_ad_html): assert ( parsing_flow.all_non_optional_fields_were_found and parsing_flow.all_found_fields_are_valid + and len(parsing_flow.field_values) == len(all_instructions) )