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


Python utils.CatalogueImporter类代码示例

本文整理汇总了Python中oscar.apps.partner.utils.CatalogueImporter的典型用法代码示例。如果您正苦于以下问题:Python CatalogueImporter类的具体用法?Python CatalogueImporter怎么用?Python CatalogueImporter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: ImportSemicolonDelimitedFileTest

class ImportSemicolonDelimitedFileTest(TestCase):

    def setUp(self):
        self.importer = CatalogueImporter(logger, delimiter=";")

    def test_import(self):
        self.importer.handle(TEST_BOOKS_SEMICOLON_CSV)
开发者ID:ButchershopCreative,项目名称:django-oscar,代码行数:7,代码来源:import_tests.py

示例2: ImportSmokeTest

class ImportSmokeTest(TestCase):

    # First row is:
    # "9780115531446","Prepare for Your Practical Driving Test",NULL,"Book","Gardners","9780115531446","10.32","6"
    #
    # Second row is (has no stock data):
    # "9780955337819","Better Photography",NULL,"Book"

    def setUp(self):
        self.importer = CatalogueImporter(logger)
        self.importer.handle(TEST_BOOKS_CSV)
        self.product = Product.objects.get(upc='9780115531446')

    def test_all_rows_are_imported(self):
        self.assertEquals(10, Product.objects.all().count())

    def test_class_is_created(self):
        try:
            ProductClass.objects.get(name="Book")
        except Product.DoesNotExist:
            self.fail()

    def test_only_one_class_is_created(self):
        self.assertEquals(1, ProductClass.objects.all().count())

    def test_item_is_created(self):
        try:
            Product.objects.get(upc="9780115531446")
        except Product.DoesNotExist:
            self.fail()

    def test_title_is_imported(self):
        self.assertEquals("Prepare for Your Practical Driving Test", self.product.title)

    def test_partner_is_created(self):
        try:
            Partner.objects.get(name="Gardners")
        except Product.DoesNotExist:
            self.fail()

    def test_stockrecord_is_created(self):
        try:
            StockRecord.objects.get(partner_sku="9780115531446")
        except Product.DoesNotExist:
            self.fail()

    def test_null_fields_are_skipped(self):
        self.assertEquals("", self.product.description)

    def test_price_is_imported(self):
        stockrecord = self.product.stockrecords.all()[0]
        self.assertEquals(D('10.32'), stockrecord.price_excl_tax)

    def test_num_in_stock_is_imported(self):
        stockrecord = self.product.stockrecords.all()[0]
        self.assertEquals(6, stockrecord.num_in_stock)
开发者ID:ButchershopCreative,项目名称:django-oscar,代码行数:56,代码来源:import_tests.py

示例3: ImportWithFlushTest

class ImportWithFlushTest(TestCase):
    def setUp(self):
        self.importer = CatalogueImporter(logger, flush=True)

    def test_items_are_flushed_by_importer(self):
        upc = "0000000000000"
        create_product(price=D("10.00"), upc=upc)

        self.importer.handle(TEST_BOOKS_CSV)

        with self.assertRaises(Product.DoesNotExist):
            Product.objects.get(upc=upc)
开发者ID:RooshRoosh,项目名称:django-oscar,代码行数:12,代码来源:import_tests.py

示例4: CommandEdgeCasesTest

class CommandEdgeCasesTest(TestCase):
    def setUp(self):
        self.importer = CatalogueImporter(logger)

    def test_sending_no_file_argument_raises_exception(self):
        self.importer.afile = None
        with self.assertRaises(ImportError):
            self.importer.handle()

    def test_sending_directory_as_file_raises_exception(self):
        self.importer.afile = "/tmp"
        with self.assertRaises(ImportError):
            self.importer.handle()

    def test_importing_nonexistant_file_raises_exception(self):
        self.importer.afile = "/tmp/catalogue-import.zgvsfsdfsd"
        with self.assertRaises(ImportError):
            self.importer.handle()
开发者ID:RooshRoosh,项目名称:django-oscar,代码行数:18,代码来源:import_tests.py

示例5: setUp

 def setUp(self):
     self.importer = CatalogueImporter(logger)
     self.importer.handle(TEST_BOOKS_CSV)
     self.product = Product.objects.get(upc='9780115531446')
开发者ID:ButchershopCreative,项目名称:django-oscar,代码行数:4,代码来源:import_tests.py


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