當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。