File tree Expand file tree Collapse file tree 3 files changed +152
-0
lines changed
fixtures/select_one_from_previous_answers Expand file tree Collapse file tree 3 files changed +152
-0
lines changed Original file line number Diff line number Diff line change 1+ # coding: utf-8
2+
3+ from __future__ import (unicode_literals , print_function ,
4+ absolute_import , division )
5+
6+ '''
7+ select_one_from_previous_answers
8+
9+ '''
10+
11+ from ..load_fixture_json import load_fixture_json
12+
13+ DATA = {
14+ 'title' : 'Household survey with select_one from previous answers' ,
15+ 'id_string' : 'select_one_from_previous_answers' ,
16+ 'versions' : [
17+ load_fixture_json ('select_one_from_previous_answers/v1' ),
18+ ],
19+ }
Original file line number Diff line number Diff line change 1+ {
2+ "version" : " romev1" ,
3+ "content" : {
4+ "survey" : [
5+ {
6+ "name" : " Q1" ,
7+ "type" : " integer" ,
8+ "label" : [
9+ " How many members live in your family?"
10+ ]
11+ },
12+ {
13+ "name" : " FM" ,
14+ "type" : " begin_repeat" ,
15+ "label" : [
16+ " Family Members"
17+ ],
18+ "repeat_count" : " ${Q1}"
19+ },
20+ {
21+ "name" : " Q2" ,
22+ "type" : " text" ,
23+ "label" : [
24+ " Name?"
25+ ]
26+ },
27+ {
28+ "name" : " Q3" ,
29+ "type" : " integer" ,
30+ "label" : [
31+ " ${Q2}'s age?"
32+ ]
33+ },
34+ {
35+ "type" : " end_repeat"
36+ },
37+ {
38+ "name" : " Q4" ,
39+ "type" : " select_one" ,
40+ "label" : [
41+ " Select the head of the household."
42+ ],
43+ "select_from_list_name" : " ${Q2}"
44+ },
45+ {
46+ "name" : " Q5" ,
47+ "type" : " select_one" ,
48+ "label" : [
49+ " Select the youngest child (<18 years) who is currently available in the family."
50+ ],
51+ "choice_filter" : " ${Q3} < 18" ,
52+ "select_from_list_name" : " ${Q2}"
53+ }
54+ ]
55+ },
56+ "submissions" : [
57+ {
58+ "FM" : [
59+ {
60+ "FM/Q2" : " Julius Caesar" ,
61+ "FM/Q3" : " 53"
62+ },
63+ {
64+ "FM/Q2" : " Gaius Octavius" ,
65+ "FM/Q3" : " 17"
66+ }
67+ ],
68+ "FM_count" : " 2" ,
69+ "Q1" : " 2" ,
70+ "Q4" : " Julius Caesar" ,
71+ "Q5" : " Gaius Octavius" ,
72+ "meta/versionID" : " romev1" ,
73+ "meta/instanceID" : " uuid:40805f86-2638-46f1-ab5a-72f4632474b5"
74+ }
75+ ]
76+ }
Original file line number Diff line number Diff line change @@ -415,6 +415,63 @@ def test_repeats(self):
415415 ])
416416 )
417417
418+ def test_select_one_from_previous_answers (self ):
419+ title , schemas , submissions = build_fixture (
420+ 'select_one_from_previous_answers'
421+ )
422+ fp = FormPack (schemas , title )
423+ options = {'versions' : 'romev1' }
424+ export = fp .export (** options ).to_dict (submissions )
425+ expected_dict = OrderedDict (
426+ [
427+ (
428+ 'Household survey with select_one from previous answers' ,
429+ {
430+ 'fields' : [
431+ 'Q1' ,
432+ 'Q4' ,
433+ 'Q5' ,
434+ '_index' ,
435+ ],
436+ 'data' : [
437+ [
438+ '2' ,
439+ 'Julius Caesar' ,
440+ 'Gaius Octavius' ,
441+ 1 ,
442+ ]
443+ ],
444+ },
445+ ),
446+ (
447+ 'FM' ,
448+ {
449+ 'fields' : [
450+ 'Q2' ,
451+ 'Q3' ,
452+ '_parent_table_name' ,
453+ '_parent_index' ,
454+ ],
455+ 'data' : [
456+ [
457+ 'Julius Caesar' ,
458+ '53' ,
459+ 'Household survey with select_one from previous answers' ,
460+ 1 ,
461+ ],
462+ [
463+ 'Gaius Octavius' ,
464+ '17' ,
465+ 'Household survey with select_one from previous answers' ,
466+ 1 ,
467+ ],
468+ ],
469+ },
470+ ),
471+ ]
472+ )
473+ self .assertEqual (export , expected_dict )
474+
418475 def test_nested_repeats_with_copy_fields (self ):
419476 title , schemas , submissions = build_fixture (
420477 'nested_grouped_repeatable' )
You can’t perform that action at this time.
0 commit comments