コード例 #1
0
ファイル: test_product.py プロジェクト: jsok/scribbly
    def test_product_collection_empty_with_master(self):
        collection = ProductCollectionFactory.build(name="Empty Collection")
        p = ProductFactory.build()
        p.set_as_master_of_collection(collection)

        self.assertEquals(0, len(collection), "Collection is not empty")
        self.assertIsNotNone(collection.master, "Collection Master should be set")
コード例 #2
0
    def test_product_collection_empty_with_master(self):
        collection = ProductCollectionFactory.build(name="Empty Collection")
        p = ProductFactory.build()
        p.set_as_master_of_collection(collection)

        self.assertEquals(0, len(collection), "Collection is not empty")
        self.assertIsNotNone(collection.master,
                             "Collection Master should be set")
コード例 #3
0
ファイル: test_product.py プロジェクト: jsok/scribbly
    def test_product_collection_replacement_group(self):
        collection = ProductCollectionFactory.build(name="PROD000 Variants")
        master = ProductFactory.build(sku="PROD000")
        replacements = [
            ProductFactory.build(sku="REPLACEMENT-A"),
            ProductFactory.build(sku="REPLACEMENT-B"),
        ]

        master.set_as_master_of_collection(collection)
        map(lambda p: p.join_collection(collection), replacements)

        self.assertEquals(2, len(collection), "Incorrect number of products in collection")
        self.assertIsNotNone(collection.master, "Collection master should not be set")

        for p in replacements:
            self.assertEquals(1, len(p.collections), "%s is not aware it's in a collection" % p.sku)
コード例 #4
0
ファイル: test_product.py プロジェクト: jsok/scribbly
    def test_product_collection_variant_group(self):
        products = [
            ProductFactory.build(sku="PROD000-A"),
            ProductFactory.build(sku="PROD000-B"),
            ProductFactory.build(sku="PROD000-C"),
        ]
        collection = ProductCollectionFactory.build(name="PROD000 Variants")
        map(lambda p: p.join_collection(collection), products)

        self.assertEquals(3, len(collection), "Incorrect number of products in collection")
        self.assertIsNone(collection.master, "Collection master should not be set")

        for p in products:
            self.assertEquals(1, len(p.collections), "%s is not aware it's in a collection" % p.sku)

        products[0].leave_collection(collection)
        self.assertEquals(2, len(collection), "Incorrect number of products in collection")
        self.assertEquals(0, len(products[0].collections), "PROD000-A did not leave collection")
コード例 #5
0
    def test_product_collection_replacement_group(self):
        collection = ProductCollectionFactory.build(name="PROD000 Variants")
        master = ProductFactory.build(sku="PROD000")
        replacements = [
            ProductFactory.build(sku="REPLACEMENT-A"),
            ProductFactory.build(sku="REPLACEMENT-B"),
        ]

        master.set_as_master_of_collection(collection)
        map(lambda p: p.join_collection(collection), replacements)

        self.assertEquals(2, len(collection),
                          "Incorrect number of products in collection")
        self.assertIsNotNone(collection.master,
                             "Collection master should not be set")

        for p in replacements:
            self.assertEquals(1, len(p.collections),
                              "%s is not aware it's in a collection" % p.sku)
コード例 #6
0
    def test_product_collection_variant_group(self):
        products = [
            ProductFactory.build(sku="PROD000-A"),
            ProductFactory.build(sku="PROD000-B"),
            ProductFactory.build(sku="PROD000-C"),
        ]
        collection = ProductCollectionFactory.build(name="PROD000 Variants")
        map(lambda p: p.join_collection(collection), products)

        self.assertEquals(3, len(collection),
                          "Incorrect number of products in collection")
        self.assertIsNone(collection.master,
                          "Collection master should not be set")

        for p in products:
            self.assertEquals(1, len(p.collections),
                              "%s is not aware it's in a collection" % p.sku)

        products[0].leave_collection(collection)
        self.assertEquals(2, len(collection),
                          "Incorrect number of products in collection")
        self.assertEquals(0, len(products[0].collections),
                          "PROD000-A did not leave collection")
コード例 #7
0
    def test_product_collection_empty(self):
        collection = ProductCollectionFactory.build(name="Empty Collection")

        self.assertEquals(0, len(collection), "Collection is not empty")
        self.assertIsNone(collection.master,
                          "Collection Master should not be set")
コード例 #8
0
ファイル: test_product.py プロジェクト: jsok/scribbly
    def test_product_collection_empty(self):
        collection = ProductCollectionFactory.build(name="Empty Collection")

        self.assertEquals(0, len(collection), "Collection is not empty")
        self.assertIsNone(collection.master, "Collection Master should not be set")