当前位置: 首页>>代码示例>>Python>>正文


Python SpreadsheetImport.mapping['ID']方法代码示例

本文整理汇总了Python中spreadsheetimport.SpreadsheetImport.mapping['ID']方法的典型用法代码示例。如果您正苦于以下问题:Python SpreadsheetImport.mapping['ID']方法的具体用法?Python SpreadsheetImport.mapping['ID']怎么用?Python SpreadsheetImport.mapping['ID']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在spreadsheetimport.SpreadsheetImport的用法示例。


在下文中一共展示了SpreadsheetImport.mapping['ID']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_analyze

# 需要导入模块: from spreadsheetimport import SpreadsheetImport [as 别名]
# 或者: from spreadsheetimport.SpreadsheetImport import mapping['ID'] [as 别名]
    def test_analyze(self):

        testimport = SpreadsheetImport(StringIO(csv_file), [self.collection])

        self.assertFalse(testimport.analyzed)

        data = testimport.analyze()

        self.assertTrue(testimport.analyzed)

        self.assertEqual(2, len(data))

        self.assertEqual('A001', data[0]['ID'][0])
        self.assertEqual('a001.jpg', data[0]['Filename'][0])
        self.assertEqual('Test', data[0]['Title'][0])
        self.assertEqual('Knab, Andreas', data[0]['Creator'][0])
        self.assertEqual('Harrisonburg, VA', data[0]['Location'][0])
        self.assertEqual(None, data[0]['Unused'])

        self.assertEqual('A002', data[1]['ID'][0])
        self.assertEqual('a002.jpg', data[1]['Filename'][0])
        self.assertEqual('Another Test', data[1]['Title'][0])
        self.assertEqual('Andreas Knab;John Doe', data[1]['Creator'][0])
        self.assertEqual('Virginia', data[1]['Location'][0])
        self.assertEqual(None, data[1]['Unused'])

        # These don't match anything
        self.assertEqual(None, testimport.mapping['ID'])
        self.assertEqual(None, testimport.mapping['Filename'])
        self.assertEqual(None, testimport.mapping['Unused'])

        # These should match standards fields
        self.assertNotEqual(None, testimport.mapping['Title'])
        self.assertNotEqual(None, testimport.mapping['Creator'])
        self.assertNotEqual(None, testimport.mapping['Location'])

        self.assertEqual(None, testimport.get_identifier_field())

        # Map the ID field and try again
        testimport.mapping['ID'] = Field.objects.get(
            name='identifier', standard__prefix='dc')
        self.assertEqual('ID', testimport.get_identifier_field())
开发者ID:hanleybrand,项目名称:rooibos,代码行数:44,代码来源:tests.py


注:本文中的spreadsheetimport.SpreadsheetImport.mapping['ID']方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。