Example #1
0
 def test_model_return_category(self):
     response = Category.get_category()
     self.assertNotIsInstance(response, str)
     try:
         for res in response:
             pass
     except:
         self.fail('Response should be iterable')
Example #2
0
def home_page(request):
    if not request.session.get(CART_ID_SESSION_KEY, None):
        shopping_cart = ShoppingCart.objects.create()
        request.session[CART_ID_SESSION_KEY] = shopping_cart.id
    categories = Category.get_category()
    return render(request, "home.html", {'categories': categories})