コード例 #1
0
 def test_dont_override_columns(self):
     table = [{
         'ID': 'id1',
         'Column1': 'val1',
         'Column2': 'val1b'
     }, {
         'ID': 'id2'
     }, {
         'ID': 'id3',
         'Column1': 'val3'
     }, {
         'ID': 'id4'
     }]
     new_table = p.fill_with_previous(table, ['Column1', 'Column2'])
     expected = [{
         'ID': 'id1',
         'Column1': 'val1',
         'Column2': 'val1b'
     }, {
         'ID': 'id2',
         'Column1': 'val1',
         'Column2': 'val1b'
     }, {
         'ID': 'id3',
         'Column1': 'val3'
     }, {
         'ID': 'id4',
         'Column1': 'val3'
     }]
     self.assertEqual(new_table, expected)
コード例 #2
0
 def test_keep_filling(self):
     table = [{
         'ID': 'id1',
         'Column1': 'val1'
     }, {
         'ID': 'id2'
     }, {
         'ID': 'id3'
     }, {
         'ID': 'id4',
         'Column1': 'val4'
     }]
     new_table = p.fill_with_previous(table, ['Column1'])
     expected = [{
         'ID': 'id1',
         'Column1': 'val1'
     }, {
         'ID': 'id2',
         'Column1': 'val1'
     }, {
         'ID': 'id3',
         'Column1': 'val1'
     }, {
         'ID': 'id4',
         'Column1': 'val4'
     }]
     self.assertEqual(new_table, expected)
コード例 #3
0
 def test_fill_multiple(self):
     table = [{
         'ID': 'id1',
         'Column1': 'val1',
         'Column2': 'val1b'
     }, {
         'ID': 'id2'
     }, {
         'ID': 'id3',
         'Column1': 'val3',
         'Column2': 'val3b'
     }]
     new_table = p.fill_with_previous(table, ['Column1', 'Column2'])
     expected = [{
         'ID': 'id1',
         'Column1': 'val1',
         'Column2': 'val1b'
     }, {
         'ID': 'id2',
         'Column1': 'val1',
         'Column2': 'val1b'
     }, {
         'ID': 'id3',
         'Column1': 'val3',
         'Column2': 'val3b'
     }]
     self.assertEqual(new_table, expected)
コード例 #4
0
 def test_cant_fill_first_row(self):
     table = [{
         'ID': 'id1'
     }, {
         'ID': 'id2',
         'Column1': 'val2'
     }, {
         'ID': 'id3',
         'Column1': 'val3'
     }]
     new_table = p.fill_with_previous(table, ['Column1'])
     expected = [{
         'ID': 'id1'
     }, {
         'ID': 'id2',
         'Column1': 'val2'
     }, {
         'ID': 'id3',
         'Column1': 'val3'
     }]
     self.assertEqual(new_table, expected)