Esempio n. 1
0
    def test_release_info_would_be_deleted_when_product_was_deleted(self, session):
        product = Product(name="foo")

        release_1 = ProductReleaseInfo(price=100)
        release_2 = ProductReleaseInfo(price=200)

        product.release_infos.append(release_1)
        product.release_infos.append(release_2)
        product.save()
        session.commit()

        Product.destroy([product.id])
        session.commit()

        assert not ProductReleaseInfo.all()
Esempio n. 2
0
    def test_images_would_be_deleted_when_product_was_deleted(self, session):
        product = Product(name="foo")

        image_1 = ProductOfficialImage(url="http://foo.com/img1.jpg")
        image_2 = ProductOfficialImage(url="http://foo.com/img2.jpg")

        product.official_images.append(image_1)
        product.official_images.append(image_2)
        product.save()
        session.commit()

        Product.destroy([product.id])
        session.commit()

        assert not ProductOfficialImage.all()
Esempio n. 3
0
    def test_delete_product_and_association_but_not_effect_worker(self, session):
        from figure_hook.Models.relation_table import (product_paintwork_table,
                                                       product_sculptor_table)
        p = Product(name="foo")
        master = Sculptor(name="master")
        newbie = Paintwork(name="newbie")

        p.paintworks.append(newbie)
        p.sculptors.append(master)
        p.save()
        session.commit()

        Product.destroy([p.id])
        session.commit()

        s_asso = session.query(product_sculptor_table).all()
        p_asso = session.query(product_paintwork_table).all()
        assert not s_asso
        assert not p_asso
        assert Sculptor.all()
        assert Paintwork.all()