Ejemplo n.º 1
0
    def setUpTestData(cls):
        cls.admin_user = f.UserFactory(is_staff=True)
        cls.restaurant_admin_user = f.UserFactory()
        cls.test_user = f.UserFactory()
        cls.test_restaurant = \
            f.RestaurantFactory(admin_users=[cls.restaurant_admin_user])

        cls.current_test_url = reverse(
            'restaurants:restaurant_delete',
            kwargs={'restaurant_slug': cls.test_restaurant.slug})
Ejemplo n.º 2
0
    def setUpTestData(cls):
        cls.restaurant_admin_user = f.UserFactory()
        cls.test_restaurant = \
            f.RestaurantFactory(admin_users=[cls.restaurant_admin_user])
        cls.test_menu = \
            f.MenuFactory(restaurant=cls.test_restaurant)

        cls.current_test_url = reverse(
            'restaurants:restaurant_detail',
            kwargs={'restaurant_slug': cls.test_restaurant.slug})
Ejemplo n.º 3
0
    def setUp(self):
        self.test_restaurant = \
            f.RestaurantFactory(admin_users=[self.restaurant_admin_user])

        # generate test url
        self.kwargs = {'restaurant_pk': self.test_restaurant.pk}
        self.current_test_url = \
            reverse('api:restaurant_detail', kwargs=self.kwargs)

        self.client.login(username=self.restaurant_admin_user.username,
                          password=c.TEST_USER_PASSWORD)
Ejemplo n.º 4
0
    def test_template_shows_restaurants(self):
        test_restaurants = []

        # 0 restaurants
        self.assertIn("You have not registered any restaurants.", self.html)

        # 1 restaurant
        test_restaurants.append(
            f.RestaurantFactory(admin_users=[self.restaurant_admin_user]))
        self.client.get(self.current_test_url)
        self.response = self.client.get(self.current_test_url)
        self.html = unescape(self.response.content.decode('utf-8'))
        self.assertIn(f"{test_restaurants[0].name}", self.html)

        # 2 restaurants
        test_restaurants.append(
            f.RestaurantFactory(admin_users=[self.restaurant_admin_user]))
        self.client.get(self.current_test_url)
        self.response = self.client.get(self.current_test_url)
        self.html = unescape(self.response.content.decode('utf-8'))
        self.assertIn(f"{test_restaurants[0].name}", self.html)
        self.assertIn(f"{test_restaurants[1].name}", self.html)
Ejemplo n.º 5
0
    def setUpTestData(cls):
        cls.view = views.MenuList

        # create model objects
        cls.test_user = f.UserFactory()
        cls.restaurant_admin_user = f.UserFactory()
        cls.test_restaurant = f.RestaurantFactory()
        cls.test_menus = f.MenuFactory.create_batch(
            size=3,
            restaurant=cls.test_restaurant,
            admin_users=[cls.restaurant_admin_user])

        # generate test url
        cls.kwargs = {'restaurant_pk': cls.test_menus[0].pk}
        cls.current_test_url = reverse('api:menu_list', kwargs=cls.kwargs)
Ejemplo n.º 6
0
    def setUpTestData(cls):
        cls.test_permission = UserHasRestaurantPermissionsMixin()
        cls.request = RequestFactory().get('/')

        # create users
        cls.test_user = f.UserFactory()
        cls.restaurant_admin_user = f.UserFactory()
        cls.admin_user = f.UserFactory(is_staff=True)

        # create restaurant objects
        cls.test_restaurant = \
            f.RestaurantFactory(admin_users=[cls.restaurant_admin_user])
        cls.test_menu = f.MenuFactory(restaurant=cls.test_restaurant)
        cls.test_menusection = f.MenuSectionFactory(menu=cls.test_menu)
        cls.test_menuitem = f.MenuItemFactory(menusection=cls.test_menusection)
Ejemplo n.º 7
0
    def setUpTestData(cls):
        cls.test_permission = HasRestaurantPermissionsOrReadOnly()
        cls.factory = APIRequestFactory()

        # create users
        cls.unprivileged_user = f.UserFactory(username='******')
        cls.permitted_user = f.UserFactory(username='******')
        cls.admin_user = f.UserFactory(username='******', is_staff=True)

        # create restaurant objects and add permitted user to admin_users
        cls.test_restaurant = f.RestaurantFactory(
            admin_users=[cls.permitted_user])
        cls.test_menu = f.MenuFactory(restaurant=cls.test_restaurant)
        cls.test_menusection = f.MenuSectionFactory(menu=cls.test_menu)
        cls.test_menuitem = f.MenuItemFactory(menusection=cls.test_menusection)
Ejemplo n.º 8
0
    def setUp(self):
        self.test_restaurant = \
            f.RestaurantFactory(admin_users=[self.restaurant_admin_user])

        # login as authorized user
        self.client.login(username=self.restaurant_admin_user.username,
                          password=c.TEST_USER_PASSWORD)

        self.current_test_url = reverse(
            'restaurants:restaurant_update',
            kwargs={'restaurant_slug': self.test_restaurant.slug})

        self.response = self.client.get(self.current_test_url)
        self.context = self.response.context
        self.html = unescape(self.response.content.decode('utf-8'))
        self.view = self.response.context['view']
Ejemplo n.º 9
0
    def setUpTestData(cls):
        cls.serializer = serializers.MenuSerializer

        cls.restaurant_admin_user = f.UserFactory()
        cls.test_restaurant = \
            f.RestaurantFactory(admin_users=[cls.restaurant_admin_user])