From 3800323c3668cafdb5fc611c8284c8a8d7709751 Mon Sep 17 00:00:00 2001 From: "John N. Milner" Date: Sat, 15 Jun 2024 11:08:06 -0400 Subject: [PATCH] Add failing test for #322 `Mismatched labels and translations` error when attempting to load a schema that contains multiple languages as well as a `select_one_from_file` or `select_multiple_from_file` that has been expanded to have a `file` column as performed by #314 --- tests/test_exports.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/test_exports.py b/tests/test_exports.py index 70f299a..a1dea9d 100644 --- a/tests/test_exports.py +++ b/tests/test_exports.py @@ -376,6 +376,34 @@ def test_translations_labels_mismatch(self): with self.assertRaises(TranslationError): FormPack(schemas, title) + def test_translations_with_select_multiple_from_file(self): + title, schemas, submissions = restaurant_profile + + # Add a `select_multiple_from_file` question to existing `rpV4` schema + assert schemas[-1]['version'] == 'rpV4' + schemas[-1]['content']['survey'].append( + { + 'type': 'select_multiple_from_file suppliers.csv', + 'name': 'suppliers', + 'label::english': 'suppliers', + 'label::french': 'fournisseurs', + } + ) + fp = FormPack(schemas[-1:], title) + + # Expect that a `file` column has been added; see + # `test_expand_content.test_expand_select_x_from_file()` + assert ( + fp.versions['rpV4'].schema['content']['survey'][-1]['file'] + == 'suppliers.csv' + ) + + # Feed this schema with `file` back into formpack again + fp = FormPack([fp.versions['rpV4'].schema], title) + + # Fails here with + # `formpack.errors.TranslationError: Mismatched labels and translations: [restaurant name, nom du restaurant] [english, french, None] 2!=3` + def test_simple_nested_grouped_repeatable(self): title, schemas, submissions = build_fixture( 'simple_nested_grouped_repeatable'