def test_nested_repeat(self):
     table = TableConfiguration(
         path=[PathNode(name='foo', is_repeat=True), PathNode(name='bar', is_repeat=True)],
     )
     self.assertEqual(
         table._get_sub_documents(
             {
                 'foo': [
                     {
                         'bar': [
                             {'baz': 'a'},
                             {'baz': 'b'}
                         ],
                     },
                     {
                         'bar': [
                             {'baz': 'c'}
                         ],
                     },
                 ],
             },
             0
         ),
         [
             DocRow(row=(0, 0, 0), doc={'baz': 'a'}),
             DocRow(row=(0, 0, 1), doc={'baz': 'b'}),
             DocRow(row=(0, 1, 0), doc={'baz': 'c'}),
         ]
     )
 def test_nested_repeat(self):
     table = TableConfiguration(
         path=[PathNode(name='foo', is_repeat=True), PathNode(name='bar', is_repeat=True)],
     )
     self.assertEqual(
         table._get_sub_documents(
             {
                 'foo': [
                     {
                         'bar': [
                             {'baz': 'a'},
                             {'baz': 'b'}
                         ],
                     },
                     {
                         'bar': [
                             {'baz': 'c'}
                         ],
                     },
                 ],
             },
             0
         ),
         [
             DocRow(row=(0, 0, 0), doc={'baz': 'a'}),
             DocRow(row=(0, 0, 1), doc={'baz': 'b'}),
             DocRow(row=(0, 1, 0), doc={'baz': 'c'}),
         ]
     )
    def test_basic(self):

        table = TableConfiguration(path=[])
        self.assertEqual(
            table._get_sub_documents(
                {'foo': 'a'},
                0
            ),
            [
                DocRow(row=(0,), doc={'foo': 'a'})
            ]
        )
    def test_basic(self):

        table = TableConfiguration(path=[])
        self.assertEqual(
            table._get_sub_documents(
                {'foo': 'a'},
                0
            ),
            [
                DocRow(row=(0,), doc={'foo': 'a'})
            ]
        )
示例#5
0
 def test_single_iteration_repeat(self):
     table = TableConfiguration(path=[
         PathNode(name='group1', is_repeat=False),
         PathNode(name='repeat1', is_repeat=True)
     ], )
     self.assertEqual(
         table._get_sub_documents({'group1': {
             'repeat1': {
                 'baz': 'a'
             },
         }}, 0), [
             DocRow(row=(0, 0), doc={'baz': 'a'}),
         ])
示例#6
0
 def test_simple_repeat(self):
     table = TableConfiguration(path=[PathNode(name="foo", is_repeat=True)])
     self.assertEqual(
         table._get_sub_documents({'foo': [
             {
                 'bar': 'a'
             },
             {
                 'bar': 'b'
             },
         ]}, 0), [
             DocRow(row=(0, 0), doc={'bar': 'a'}),
             DocRow(row=(0, 1), doc={'bar': 'b'})
         ])
 def test_single_iteration_repeat(self):
     table = TableConfiguration(
         path=[PathNode(name='group1', is_repeat=False), PathNode(name='repeat1', is_repeat=True)],
     )
     self.assertEqual(
         table._get_sub_documents(
             {
                 'group1': {
                     'repeat1': {
                         'baz': 'a'
                     },
                 }
             },
             0
         ),
         [
             DocRow(row=(0, 0), doc={'baz': 'a'}),
         ]
     )
 def test_simple_repeat(self):
     table = TableConfiguration(
         path=[PathNode(name="foo", is_repeat=True)]
     )
     self.assertEqual(
         table._get_sub_documents(
             {
                 'foo': [
                     {'bar': 'a'},
                     {'bar': 'b'},
                 ]
             },
             0
         ),
         [
             DocRow(row=(0, 0), doc={'bar': 'a'}),
             DocRow(row=(0, 1), doc={'bar': 'b'})
         ]
     )