Пример #1
0
    def test_search_restaurant_by_key_ok_partial_name(self):
        """
        This test unit test the service to perform the search by keyword of the restaurants
        on persistence
        """
        form = RestaurantForm()
        form.name.data = "rest_mock_{}".format(randrange(10000))
        form.phone.data = "096321343{}".format(randrange(10000))
        form.lat.data = 12
        form.lon.data = 12
        form.n_tables.data = 50
        form.covid_measures.data = "Random comment {}".format(randrange(10000))
        form.cuisine.data = ["Italian food"]
        form.open_days.data = ["0"]
        form.open_lunch.data = datetime.time(datetime(2020, 7, 1, 12, 00))
        form.close_lunch.data = datetime.time(datetime(2020, 7, 1, 12, 00))
        form.open_dinner.data = datetime.time(datetime(2020, 7, 1, 18, 00))
        form.close_dinner.data = datetime.time(datetime(2020, 6, 1, 22, 00))

        user = create_user_on_db(randrange(6000, 9000), role_id=2)
        assert user is not None
        assert user.role_id == 2

        restaurant = RestaurantServices.create_new_restaurant(
            form, user.id, 6, user.email)
        assert restaurant is not None
        rest_by_name = RestaurantServices.get_restaurants_by_keyword(
            name=restaurant.name)
        assert len(rest_by_name) is 1

        del_user_on_db(user.id)
        RestaurantServices.delete_restaurant(restaurant.id)
Пример #2
0
    def test_create_restaurant(self):
        """
        test create user
        :return:
        """
        form = RestaurantForm()
        form.name.data = "rest_mock_{}".format(randrange(10000))
        form.phone.data = "096321343{}".format(randrange(10000))
        form.lat.data = 12
        form.lon.data = 12
        form.n_tables.data = 50
        form.covid_measures.data = "Random comment {}".format(randrange(10000))
        form.cuisine.data = ["Italian food"]
        form.open_days.data = ["0"]
        form.open_lunch.data = datetime.time(datetime(2020, 7, 1, 12, 00))
        form.close_lunch.data = datetime.time(datetime(2020, 7, 1, 12, 00))
        form.open_dinner.data = datetime.time(datetime(2020, 7, 1, 18, 00))
        form.close_dinner.data = datetime.time(datetime(2020, 6, 1, 22, 00))

        user = create_user_on_db(randrange(1, 60000), role_id=2)
        assert user is not None
        assert user.role_id == 2

        restaurant = RestaurantServices.create_new_restaurant(
            form, user.id, 6, user.email)
        assert restaurant is not None

        ## This call should be delete also the restaurants
        del_user_on_db(user.id)
        RestaurantServices.delete_restaurant(restaurant.id)
Пример #3
0
    def test_restaurant_name(self):
        """
        check the function that return the restaurant name
        """
        form = RestaurantForm()
        form.name.data = "rest_mock_{}".format(randrange(10000))
        form.phone.data = "096321343{}".format(randrange(10000))
        form.lat.data = 12
        form.lon.data = 12
        form.n_tables.data = 50
        form.covid_measures.data = "Random comment {}".format(randrange(10000))
        form.cuisine.data = ["Italian food"]
        form.open_days.data = ["0"]
        form.open_lunch.data = datetime.time(datetime(2020, 7, 1, 12, 00))
        form.close_lunch.data = datetime.time(datetime(2020, 7, 1, 12, 00))
        form.open_dinner.data = datetime.time(datetime(2020, 7, 1, 18, 00))
        form.close_dinner.data = datetime.time(datetime(2020, 6, 1, 22, 00))

        user = create_user_on_db(randrange(10, 50000), role_id=2)
        assert user is not None
        assert user.role_id == 2

        restaurant = RestaurantServices.create_new_restaurant(
            form, user, 6, user.email)
        assert restaurant is not None

        name = RestaurantServices.get_restaurant_name(restaurant.id)
        assert restaurant.name == name

        ## This call should be delete also the restaurants
        # At this point also the review should be killed with the restaurants
        del_user_on_db(user.id)
        RestaurantServices.delete_restaurant(restaurant.id)
Пример #4
0
    def test_three_reviews(self):
        """
        check the three reviews fetcher
        """
        form = RestaurantForm()
        form.name.data = "rest_mock_{}".format(randrange(10000))
        form.phone.data = "096321343{}".format(randrange(10000))
        form.lat.data = 12
        form.lon.data = 12
        form.n_tables.data = 50
        form.covid_measures.data = "Random comment {}".format(randrange(10000))
        form.cuisine.data = ["Italian food"]
        form.open_days.data = ["0"]
        form.open_lunch.data = datetime.time(datetime(2020, 7, 1, 12, 00))
        form.close_lunch.data = datetime.time(datetime(2020, 7, 1, 12, 00))
        form.open_dinner.data = datetime.time(datetime(2020, 7, 1, 18, 00))
        form.close_dinner.data = datetime.time(datetime(2020, 6, 1, 22, 00))

        user = create_user_on_db(randrange(10, 50000), role_id=2)
        assert user is not None
        assert user.role_id == 2

        restaurant = RestaurantServices.create_new_restaurant(
            form, user.id, 6, user.email)
        assert restaurant is not None

        reviewer = create_user_on_db(randrange(10, 50000), role_id=3)

        review1 = RestaurantServices.review_restaurant(restaurant.id,
                                                       reviewer.email, 5,
                                                       "test1")
        assert review1 is not None
        review2 = RestaurantServices.review_restaurant(restaurant.id,
                                                       reviewer.email, 4,
                                                       "test2")
        assert review2 is not None
        review3 = RestaurantServices.review_restaurant(restaurant.id,
                                                       reviewer.email, 3,
                                                       "test3")
        assert review3 is not None

        three_reviews = RestaurantServices.get_three_reviews(restaurant.id)
        assert three_reviews is not None
        assert len(three_reviews) == 3

        ## This call should be delete also the restaurants
        # At this point also the review should be killed with the restaurants
        del_user_on_db(user.id)
        del_user_on_db(reviewer.id)
        RestaurantServices.delete_restaurant(restaurant.id)