Example #1
0
    def test_crud(self):
        '''
        Create, store, update, and delete a rich product.
        '''

        # create a product
        from shop_richproduct.models import RichProduct
        product = RichProduct()
        product.name = "Test Product"
        product.slug = "test-product"
        product.description = "this is a test product"
        product.unit_price = 6.50
        product.active = True

        # save it
        product.save()
        product = None

        # retrieve it
        product = RichProduct.objects.get(slug="test-product")

        # verify it's properties
        self.assertEquals(product.name, "Test Product")
        self.assertEquals(product.slug, "test-product")
        self.assertEquals(product.description, "this is a test product")
        self.assertEquals(product.unit_price, 6.50)
        self.assertEquals(product.active, True)

        # delete it
        product.delete()
        product = None
Example #2
0
    def setUp(self):
        """
        Set up the test environment.
        """

        # enable debug mode
        os.environ["DEBUG"] = "True"

        # create sample products
        product = RichProduct()
        product.name = "Apollo"
        product.slug = "apollo"
        product.active = True
        product.target = "http://www.google.com"
        product.save()

        product = RichProduct()
        product.name = "Aurora"
        product.slug = "aurora"
        product.active = True
        product.target = "http://www.google.com"
        product.save()
Example #3
0
    def test_crud(self):
        """
        Create, store, update, and delete a rich product.
        """

        # create a product
        product = RichProduct()
        product.name = "Test Product"
        product.slug = "test-product"
        product.description = "this is a test product"
        product.unit_price = 6.50
        product.active = True
        product.purchase_button_label = "Buy"

        # save it
        product.save()
        product = None

        # retrieve it
        product = RichProduct.objects.get(slug="test-product")

        # verify its properties
        self.assertEquals(product.name, "Test Product")
        self.assertEquals(product.slug, "test-product")
        self.assertEquals(product.description, "this is a test product")
        self.assertEquals(product.unit_price, 6.50)
        self.assertEquals(product.active, True)
        self.assertEquals(product.purchase_button_label, "Buy")

        # delete it
        product.delete()
        product = None