Ejemplo n.º 1
0
 def test_no_column_mapping(self, apps_mock, tree_id_mock, BridgeMock):
     channel_import = ChannelImport('test')
     mappings = {'test_attr': 'test_attr_mapped'}
     mapper = channel_import.generate_row_mapper(mappings=mappings)
     record = Mock(spec=['test_attr'])
     with self.assertRaises(AttributeError):
         mapper(record, 'test_attr')
Ejemplo n.º 2
0
 def test_column_name_mapping(self, apps_mock, tree_id_mock, BridgeMock):
     channel_import = ChannelImport('test')
     mappings = {'test_attr': 'test_attr_mapped'}
     mapper = channel_import.generate_row_mapper(mappings=mappings)
     record = MagicMock()
     record.test_attr_mapped = 'test_val'
     self.assertEqual(mapper(record, 'test_attr'), 'test_val')
Ejemplo n.º 3
0
 def test_method_mapping(self, apps_mock, tree_id_mock, BridgeMock):
     channel_import = ChannelImport('test')
     mappings = {'test_attr': 'test_map_method'}
     mapper = channel_import.generate_row_mapper(mappings=mappings)
     record = {}
     test_map_method = Mock()
     test_map_method.return_value = 'test_val'
     channel_import.test_map_method = test_map_method
     self.assertEqual(mapper(record, 'test_attr'), 'test_val')
Ejemplo n.º 4
0
 def test_base_mapper(self, apps_mock, tree_id_mock, BridgeMock):
     channel_import = ChannelImport('test')
     mapper = channel_import.generate_row_mapper()
     record = MagicMock()
     record.test_attr = 'test_val'
     self.assertEqual(mapper(record, 'test_attr'), 'test_val')