diff --git a/conservancy_beancount/pdfforms/extract.py b/conservancy_beancount/pdfforms/extract.py index 3ed18aec872a8bfe40db9ad1f4877458c8ae792f..01c792139627e1bc163cf9c395a9e5a7b67be721 100644 --- a/conservancy_beancount/pdfforms/extract.py +++ b/conservancy_beancount/pdfforms/extract.py @@ -91,7 +91,7 @@ class FormExtractor: 'name': name, }, 'description': f'{field_type} {name}', - 'value': field.fill_value(), + 'value': field.value(), } if isinstance(field, fieldmod.CheckboxField): retval['fdf']['options'] = field.options() diff --git a/setup.py b/setup.py index bfef667b2a881cd737aba47280103f8418c68984..c2b78971fff288476a39cf37b0645b77b5ab48e4 100755 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ from setuptools import setup setup( name='conservancy_beancount', description="Plugin, library, and reports for reading Conservancy's books", - version='1.15.1', + version='1.15.2', author='Software Freedom Conservancy', author_email='info@sfconservancy.org', license='GNU AGPLv3+', diff --git a/tests/pdfforms/form1_fill.fdf b/tests/pdfforms/form1_fill.fdf new file mode 100644 index 0000000000000000000000000000000000000000..0e75683a4636702c494cff368b1d06bf7d92f933 --- /dev/null +++ b/tests/pdfforms/form1_fill.fdf @@ -0,0 +1,68 @@ +%FDF-1.2 +%âãÏÓ +1 0 obj +<< +/FDF +<< +/Fields [ +<< +/T (topform) +/Kids [ + << + /T (text1_0) + /FT /Tx + /V (text 1.0) + >> + << + /T (button1) + /Kids [ + << + /FT /Btn + /T (button1_0) + /AP << /N << /1 1 0 R >> >> + /V /1 + >> + << + /FT /Btn + /T (button1_1) + /AP << /N << /2 1 0 R >> >> + >> + ] + >> + << + /T (text1_1) + /FT /Tx + /V (text 1.1) + >> + << + /T (text2_0) + /FT /Tx + /V (text 2.0) + >> + << + /T (button2) + /Kids [ + << + /FT /Btn + /T (button2_0) + /AP << /N << /1 1 0 R >> >> + >> + << + /FT /Btn + /T (button2_1) + /AP << /N << /2 1 0 R >> >> + /V /2 + >> + ] + >> +] +>>] +>> +>> +endobj +trailer + +<< +/Root 1 0 R +>> +%%EOF diff --git a/tests/test_pdfforms_extract.py b/tests/test_pdfforms_extract.py index dbacd48bb2172b6b503ae95fb6c3095bcdea9420..1f6180a6383fdae373b345cbfe74a210d6cfe23f 100644 --- a/tests/test_pdfforms_extract.py +++ b/tests/test_pdfforms_extract.py @@ -46,6 +46,15 @@ def test_extract_from_file(fdf_filename, form_key, fields_yaml): actual = extractor.extract() compare_to_yaml(actual, fields_yaml, fdf_filename, form_key) +@pytest.mark.parametrize('fdf_filename,form_key,fields_yaml', [ + ('form1_fill.fdf', 'FDF', 'form1_fill.yml'), +]) +def test_extract_from_file(fdf_filename, form_key, fields_yaml): + with testutil.test_path(f'pdfforms/{fdf_filename}').open('rb') as fdf_file: + extractor = extractmod.FormExtractor.from_file(fdf_file) + actual = extractor.extract() + compare_to_yaml(actual, fields_yaml, fdf_filename, form_key) + @pytest.mark.parametrize('fdf_filename,form_key,fields_yaml', [ ('form1.fdf', 'FDF', 'form1.yml'), ])