Skip to content

Commit

Permalink
Add failing test for #322
Browse files Browse the repository at this point in the history
`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
  • Loading branch information
jnm committed Jun 15, 2024
1 parent 95e2743 commit 3800323
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/test_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 3800323

Please sign in to comment.