Exemple #1
0
 def test_1(self):
     test.swap_implementations(abstractions, rest=False)
     make_review = abstractions.make_review
     soda_reviews = [make_review('Soda', 4.5), make_review('Soda', 4)]
     soda = make_restaurant('Soda', [127.0, 0.1], ['Restaurants', 'Breakfast & Brunch'], 1, soda_reviews)
     try:
         self.assertTrue(restaurant_ratings(soda) == [4.5, 4])
     except AssertionError:
         print("Failed Abstraction Test 1 for Problem 2")
Exemple #2
0
    def test_abstraction(self):
        test.swap_implementations(abstractions, rest_two=False)
        make_user, make_review, make_restaurant = abstractions.make_user, abstractions.make_review, abstractions.make_restaurant
        restaurant_num_ratings = abstractions.restaurant_num_ratings
        restaurant_mean_rating = abstractions.restaurant_mean_rating

        woz_reviews = [make_review('Wozniak Lounge', 4), make_review('Wozniak Lounge', 3), make_review('Wozniak Lounge', 5)]
        woz = make_restaurant('Wozniak Lounge', [127.0, 0.1], ['Restaurants', 'Pizza'], 1, woz_reviews)
        try:
            self.assertTrue(restaurant_num_ratings(woz) == 3)
        except AssertionError:
            print("Failed Abstraction Test 2 for Problem 2")

        try:
            self.assertTrue(restaurant_mean_rating(woz) == 4.0) # should be a decimal
        except AssertionError:
            print("Failed Abstraction Test 3 for Problem 2")
Exemple #3
0
import unittest
import test_functions as test
import recommend
from abstractions import *
import abstractions

old_sample = recommend.sample
test.swap_implementations(recommend)
from recommend import *


class TestProblemTwoAbstraction(unittest.TestCase):
    def test_1(self):
        test.swap_implementations(abstractions, rest=False)
        make_review = abstractions.make_review
        soda_reviews = [make_review('Soda', 4.5), make_review('Soda', 4)]
        soda = make_restaurant('Soda', [127.0, 0.1],
                               ['Restaurants', 'Breakfast & Brunch'], 1,
                               soda_reviews)
        try:
            self.assertTrue(restaurant_ratings(soda) == [4.5, 4])
        except AssertionError:
            print("Failed Abstraction Test 1 for Problem 2")

    def test_abstraction(self):
        test.swap_implementations(abstractions, rest_two=False)
        make_user, make_review, make_restaurant = abstractions.make_user, abstractions.make_review, abstractions.make_restaurant
        restaurant_num_ratings = abstractions.restaurant_num_ratings
        restaurant_mean_rating = abstractions.restaurant_mean_rating

        woz_reviews = [