def test_crud(self):
        """
        Create, store, update, and delete a catalog.
        """

        # create a catalog
        catalog = Catalog()
        catalog.name = "Test Catalog"
        catalog.slug = "test-catalog"
        catalog.save()

        catalog.products.add(RichProduct.objects.get(slug="apollo"))
        catalog.products.add(RichProduct.objects.get(slug="aurora"))
        catalog.save()

        # retrieve the catalog
        catalog = None
        catalog = Catalog.objects.get(slug="test-catalog")

        # verify catalog fields
        self.assertEquals(catalog.name, "Test Catalog")
        self.assertEquals(catalog.slug, "test-catalog")
        self.assertEquals(len(catalog.products.all()), 2)

        # verify utility methods
        self.assertEquals(unicode(catalog), catalog.name)

        # get url
        self.assertEquals(catalog.get_absolute_url(), "/catalog/test-catalog/")

        # delete the catalog
        catalog.delete()
        catalog = None
    def test_catalog_views(self):
        """
        Test the catalog list and detail views.
        """
        # create a catalog
        catalog = Catalog()
        catalog.name = "Test Catalog"
        catalog.slug = "test-catalog"
        catalog.save()

        catalog.products.add(RichProduct.objects.get(slug="apollo"))
        catalog.products.add(RichProduct.objects.get(slug="aurora"))
        catalog.save()

        client = Client(enforce_csrf_checks=True)
        response = client.get(catalog.get_absolute_url())
        self.assertEquals(response.context["catalog"].name, "Test Catalog")
        self.assertEquals(len(response.context["product_list"]), 2)