Commits

Chris Grubbs committed a6baaa6

starting on some unit tests

  • Participants
  • Parent commits 437dab3

Comments (0)

Files changed (3)

File phlombay/recipes/fixtures/auth_user.json

+[
+
+    {
+        "pk": 1,
+        "model": "auth.user",
+        "fields": {
+            "username": "user1",
+            "first_name": "User",
+            "last_name": "One",
+            "is_active": true,
+            "is_superuser": true,
+            "is_staff": true,
+            "last_login": "2012-09-22T15:10:17.710",
+            "groups": [ ],
+            "user_permissions": [ ],
+            "password": "pbkdf2_sha256$10000$hH8EfAdXp1K9$G4niugQHbzyG6+VmWIP43AXBwThGD5rcrmgD0h2blsk=",
+            "email": "user1@test.com",
+            "date_joined": "2012-09-22T10:54:12"
+        }
+    },
+    {
+        "pk": 2,
+        "model": "auth.user",
+        "fields": {
+            "username": "user2",
+            "first_name": "User",
+            "last_name": "Two",
+            "is_active": true,
+            "is_superuser": false,
+            "is_staff": false,
+            "last_login": "2012-09-22T22:18:01.604",
+            "groups": [ ],
+            "user_permissions": [ ],
+            "password": "pbkdf2_sha256$10000$Rw4ZBuCMptZZ$kIByqtCJxWgoqYLfRhoRYE15YQmLE3FTTlJhJOrhMnc=",
+            "email": "user2@test.com",
+            "date_joined": "2012-09-22T15:07:36"
+        }
+    }
+
+]

File phlombay/recipes/fixtures/recipes_recipes.json

+[
+    {
+        "pk": 1,
+        "model": "recipes.recipe",
+        "fields": {
+            "ingredients_json_blob": "[{\"quantity\": \"4\", \"unit\": \"slices\", \"ingredient\": \"prosciutto\"}, {\"quantity\": \"1/2\", \"unit\": \"\", \"ingredient\": \"melon\"}, {\"quantity\": \"12\", \"unit\": \"\", \"ingredient\": \"toothpicks\"}]",
+            "description": "A delicious party snack for you and your friends.",
+            "creator": 1,
+            "created": "2012-09-22T18:06:45.001",
+            "modified": "2012-09-22T20:52:21.141",
+            "featured": false,
+            "steps_json_blob": "[{\"text\": \"Chop melon into bite-size chunks.\"}, {\"text\": \"Place a slice of prosciutto and a chunk of melon on each toothpick.\"}]",
+            "time_required": "10 minutes",
+            "servings": 12,
+            "name": "Prosciutto & Melon Bites"
+        }
+    },
+    {
+        "pk": 2,
+        "model": "recipes.recipe",
+        "fields": {
+            "ingredients_json_blob": "[{\"ingredient\": \"baguette, split\", \"unit\": \"\", \"quantity\": \"1\"}, {\"ingredient\": \"mustard\", \"unit\": \"tbsp\", \"quantity\": \"2\"}, {\"ingredient\": \"prosciutto\", \"unit\": \"slices\", \"quantity\": \"2\"}]",
+            "description": "A simple and tasty prosciutto sandwich.",
+            "creator": 1,
+            "created": "2012-09-22T22:12:58.792",
+            "modified": "2012-09-22T22:14:52.325",
+            "featured": false,
+            "steps_json_blob": "[{\"text\": \"Spread both baguette halves with mustard.\"}, {\"text\": \"Put prosciutto slices between baguette halves.\"}]",
+            "time_required": "5 minutes",
+            "servings": 1,
+            "name": "Prosciutto Sandwich"
+        }
+    },
+	{
+        "pk": 3,
+        "model": "recipes.recipe",
+        "fields": {
+            "ingredients_json_blob": "[{\"ingredient\": \"frozen banana\", \"unit\": \"\", \"quantity\": \"1\"}, {\"ingredient\": \"vanilla protein powder\", \"unit\": \"scoop\", \"quantity\": \"1\"}, {\"ingredient\": \"almond milk\", \"unit\": \"cup\", \"quantity\": \"1\"}, {\"ingredient\": \"cocoa powder\", \"unit\": \"tablespoon\", \"quantity\": \"1\"}]",
+            "description": "Healthy shake that tastes great!",
+            "creator": 2,
+            "created": "2012-09-22T22:21:37.333",
+            "modified": "2012-09-22T22:21:37.333",
+            "featured": false,
+            "steps_json_blob": "[{\"text\": \"Place all ingredients in a blender\"}, {\"text\": \"blend on medium speed until combined\"}]",
+            "time_required": "2 minutes",
+            "servings": 1,
+            "name": "Go Bananas protein shake"
+        }
+    }
+]

File phlombay/recipes/tests.py

+from django.test import TestCase
+
+from phlombay.recipes.models import Recipe
+
+
+class RecipesTest(TestCase):
+    fixtures = ['auth_user.json',
+                'recipes_recipes.json']
+
+    def test_index(self):
+        response = self.client.get('/')
+        self.assertTemplateUsed(response, 'recipes/index.html')
+
+    def test_browse_recipes(self):
+        response = self.client.get('/recipes/browse/')
+        self.assertTemplateUsed(response, 'recipes/browse_recipes.html')
+        self.assertContains(response, 'Prosciutto & Melon Bites')
+        self.assertContains(response, 'Prosciutto Sandwich')
+        self.assertContains(response, 'Go Bananas protein shake')
+
+    def test_detail(self):
+        response = self.client.get('/recipes/detail/1/')
+        self.assertTemplateUsed(response, 'recipes/detail.html')
+        self.assertContains(response, 'Prosciutto & Melon Bites')