Skip to content

Commit 88994c3

Browse files
authored
Merge pull request #284 from kobotoolbox/283-fix-translations-labels-mismatch-error
Fix translations and labels mismatch error message
2 parents fd14074 + e2c56bc commit 88994c3

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed

src/formpack/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def __init__(self, labels=[], translations=[]):
2828
'Mismatched labels and translations: [{}] [{}] '
2929
'{}!={}'.format(
3030
', '.join(labels),
31-
', '.join(translations),
31+
', '.join(map(str, translations)),
3232
len(labels),
3333
len(translations),
3434
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# coding: utf-8
2+
'''
3+
translations_labels_mismatch
4+
'''
5+
6+
from ..load_fixture_json import load_fixture_json
7+
8+
DATA = {
9+
'title': 'Your favourite Roman emperors',
10+
'id_string': 'translations_labels_mismatch',
11+
'versions': [
12+
load_fixture_json('translations_labels_mismatch/v1'),
13+
],
14+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"version": "v1",
3+
"content": {
4+
"survey": [
5+
{
6+
"type": "text",
7+
"name": "fav_emperor",
8+
"label": [
9+
"Who is your favourite emperor?"
10+
],
11+
"hint::English (en)": "Before the decline of the Roman Empire"
12+
}
13+
],
14+
"translated": [
15+
"hint",
16+
"label"
17+
],
18+
"translations": [
19+
null
20+
]
21+
},
22+
"submissions": [
23+
{
24+
"fav_emperor": "Marcus Aurelius"
25+
}
26+
]
27+
}

tests/test_exports.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
from formpack import FormPack
1515
from formpack.constants import UNTRANSLATED
16+
from formpack.errors import TranslationError
1617
from formpack.schema.fields import (
1718
ValidationStatusCopyField,
1819
IdCopyField,
@@ -370,6 +371,11 @@ def test_submissions_of_group_exports(self):
370371
],
371372
)
372373

374+
def test_translations_labels_mismatch(self):
375+
title, schemas, submissions = build_fixture('translations_labels_mismatch')
376+
with self.assertRaises(TranslationError) as e:
377+
fp = FormPack(schemas, title)
378+
373379
def test_simple_nested_grouped_repeatable(self):
374380
title, schemas, submissions = build_fixture(
375381
'simple_nested_grouped_repeatable'

0 commit comments

Comments
 (0)