示例#1
0
 def test_process_key(self):
     nested_dict = {}
     d = {
         'repeat_1|inner_repeat_1|data_table_column_value': u'bla4',
         'repeat_0|inner_repeat_1|data_table_column_value': u'bla2',
         'repeat_1|inner_repeat_0|data_table_column_value': u'bla3',
         'repeat_0|inner_repeat_0|data_table_column_value': u'bla1',
     }
     for key, value in d.items():
         process_key(key, value, nested_dict)
     expected_dict = {
         'repeat': [
             {
                 'inner_repeat': [{
                     'data_table_column_value': u'bla1'
                 }, {
                     'data_table_column_value': u'bla2'
                 }]
             },
             {
                 'inner_repeat': [{
                     'data_table_column_value': u'bla3'
                 }, {
                     'data_table_column_value': u'bla4'
                 }]
             },
         ]
     }
     self.assertEqual(nested_dict, expected_dict)
示例#2
0
def test_process_key():
    nested_dict = {}
    d = {
        'repeat_0|inner_repeat_0|data_table_column_value': u'bla',
        'repeat_1|inner_repeat_1|data_table_column_value': u'bla2',
    }
    for key, value in d.items():
        process_key(key, value, nested_dict)
    assert len(nested_dict) == 1
示例#3
0
def test_process_key_2():
    nested_dict = {}
    d = {
        'data_tables_0|columns_0|data_table_column_value': 'Amel_HAv3.1',
        'data_tables': [],
        'directory_content': [],
    }
    for key, value in d.items():
        process_key(key, value, nested_dict)
    assert len(nested_dict) == 2
示例#4
0
 def test_process_key_2(self):
     nested_dict = {}
     d = {
         'data_tables_0|columns_0|data_table_column_value': 'Amel_HAv3.1',
         'data_tables': [],
         'directory_content': [],
     }
     for key, value in d.items():
         process_key(key, value, nested_dict)
     expected_dict = {
         'data_tables': [
             {'columns': [{'data_table_column_value': 'Amel_HAv3.1'}]}
         ],
         'directory_content': []
     }
     self.assertEqual(nested_dict, expected_dict)
示例#5
0
 def test_process_key_2(self):
     nested_dict = {}
     d = {
         'data_tables_0|columns_0|data_table_column_value': 'Amel_HAv3.1',
         'data_tables': [],
         'directory_content': [],
     }
     for key, value in d.items():
         process_key(key, value, nested_dict)
     expected_dict = {
         'data_tables': [
             {'columns': [{'data_table_column_value': 'Amel_HAv3.1'}]}
         ],
         'directory_content': []
     }
     self.assertEqual(nested_dict, expected_dict)
示例#6
0
 def test_process_key(self):
     nested_dict = {}
     d = {
         'repeat_1|inner_repeat_1|data_table_column_value': u'bla4',
         'repeat_0|inner_repeat_1|data_table_column_value': u'bla2',
         'repeat_1|inner_repeat_0|data_table_column_value': u'bla3',
         'repeat_0|inner_repeat_0|data_table_column_value': u'bla1',
     }
     for key, value in d.items():
         process_key(key, value, nested_dict)
     expected_dict = {
         'repeat': [
             {'inner_repeat': [{'data_table_column_value': u'bla1'}, {'data_table_column_value': u'bla2'}]},
             {'inner_repeat': [{'data_table_column_value': u'bla3'}, {'data_table_column_value': u'bla4'}]},
         ]
     }
     self.assertEqual(nested_dict, expected_dict)