from django.test import TestCase
from randomizer.models import Restaurant


class RandomizerTest(TestCase):
    """tests for the randomizer"""

    def test_homepage(self):
        """tests the homepage"""
        restaurant1 = Restaurant.objects.create(name='1')
        restaurant2 = Restaurant.objects.create(name='2')
        response = self.client.get('/')
        self.assertIn(response.context['restaurant'],
                      [restaurant1, restaurant2])

    def test_deleted_restaurant_bug(self):
        """tests a bug that occurs when you delete a restaurant from the DB"""
        restaurant1 = Restaurant.objects.create(name='A terrible place!')
        restaurant2 = Restaurant.objects.create(name='Foodie Heaven')
        restaurant1.delete()
        response = self.client.get('/')
        self.assertEqual(response.context['restaurant'], restaurant2)

from django.test import TestCase
from randomizer.models import Restaurant


class RandomizerTest(TestCase):
    """tests for the randomizer"""

    def test_homepage(self):
        """tests the homepage"""
        restaurant1 = Restaurant.objects.create(name='1')
        restaurant2 = Restaurant.objects.create(name='2')
        response = self.client.get('/')
        self.assertIn(response.context['restaurant'],
                      [restaurant1, restaurant2])

    def test_deleted_restaurant_bug(self):
        """tests a bug that occurs when you delete a restaurant from the DB"""
        restaurant1 = Restaurant.objects.create(name='A terrible place!')
        restaurant2 = Restaurant.objects.create(name='Foodie Heaven')
        restaurant1.delete()
        response = self.client.get('/')
        self.assertEqual(response.context['restaurant'], restaurant2)

    def test_no_restaurants_bug(self):
        """tests a bug occuring when no record exits in the restaurants DB"""
        response = self.client.get('/')
        self.assertTrue('restaurant' not in response.context)

Add a test for the bug occuring when no restaurants exist
Add a test for the bug occuring when no restaurants exist
