コード例 #1
0
    def setUp(self):
        self.c = Client()
        # Initialize dummy user
        self.dummy_user = get_user_model().objects.create(
            username="******",
            email="*****@*****.**",
        )
        self.dummy_user.set_password("test1234Restaurant")
        self.dummy_user.save()
        self.c.login(username="******", password="******")

        # Initialize temp restaurants
        self.temp_restaurant = create_restaurant(
            restaurant_name="Tacos El Paisa",
            business_address=
            "1548 St. Nicholas btw West 187th street and west 188th "
            "street, Manhattan, NY",
            yelp_detail=None,
            postcode="10040",
            business_id="WavvLdfdP6g8aZTtbBQHTw",
        )
        self.temp_restaurant2 = create_restaurant(
            restaurant_name="JUST SALAD",
            business_address="252 7th Ave",
            yelp_detail=None,
            postcode="11215",
            business_id="kasdjf09j2oijlkdjsf",
        )

        self.temp_restaurant3 = create_restaurant(
            "random_name",
            "random_address",
            None,
            "random_postcode",
            "U8C69ISrhGTTubjqoVgZYg",
        )
        self.temp_restaurant.save()
        self.temp_restaurant2.save()
        self.temp_restaurant3.save()

        # user clicks to restaurants
        UserActivityLog.objects.create(
            user=self.dummy_user,
            restaurant=self.temp_restaurant,
        ).save()

        UserActivityLog.objects.create(
            user=self.dummy_user,
            restaurant=self.temp_restaurant2,
        ).save()
        UserActivityLog.objects.create(
            user=self.dummy_user,
            restaurant=self.temp_restaurant3,
        ).save()
コード例 #2
0
 def setUp(self):
     self.restaurant1 = create_restaurant(
         restaurant_name="JUST SALAD",
         business_address="252 7th Ave",
         yelp_detail=None,
         postcode="11215",
         business_id="kasdjf09j2oijlkdjsf",
     )
     self.restaurant2 = create_restaurant(
         restaurant_name="Paint N Pour Nyc",
         business_address="2080 FREDERICK DOUGLASS BLVD",
         yelp_detail=None,
         postcode="10026",
         business_id="5qWjq_Qv6O6-iGdbBZb0tg",
     )
     super(TestUserActivityLogModel, self).setUp()
コード例 #3
0
    def setUp(self):
        self.c = Client()
        # Initialize dummy user
        self.dummy_user = get_user_model().objects.create(
            username="******",
            email="*****@*****.**",
        )
        self.dummy_user.set_password("test1234Comment")
        self.dummy_user.save()

        # Initialize temp restaurant
        self.temp_restaurant = create_restaurant(
            restaurant_name="Tacos El Paisa",
            business_address=
            "1548 St. Nicholas btw West 187th street and west 188th "
            "street, Manhattan, NY",
            yelp_detail=None,
            postcode="10040",
            business_id="WavvLdfdP6g8aZTtbBQHTw",
        )
        self.temp_restaurant.save()

        # Initialize temp review
        self.temp_review = create_review(
            self.dummy_user,
            self.temp_restaurant,
            "review for tests",
            5,
        )
        self.temp_review.save()
コード例 #4
0
 def setUp(self):
     self.restaurant = create_restaurant(
         restaurant_name="JUST SALAD",
         business_address="252 7th Ave",
         yelp_detail=None,
         postcode="11215",
         business_id="kasdjf09j2oijlkdjsf",
     )
     super(TestRestaurantQuestionForm, self).setUp()
コード例 #5
0
 def test_restaurant_question_str_function(self):
     restaurant = create_restaurant(
         restaurant_name="JUST SALAD",
         business_address="252 7th Ave",
         yelp_detail=None,
         postcode="11215",
         business_id="kasdjf09j2oijlkdjsf",
     )
     q1 = RestaurantQuestion.objects.create(user=self.dummy_user,
                                            restaurant=restaurant,
                                            question="Test question??")
     self.assertEqual(str(q1), "myuser question for JUST SALAD")
コード例 #6
0
 def setUp(self):
     super(TestRestaurantAnswerForm, self).setUp()
     self.restaurant = create_restaurant(
         restaurant_name="JUST SALAD",
         business_address="252 7th Ave",
         yelp_detail=None,
         postcode="11215",
         business_id="kasdjf09j2oijlkdjsf",
     )
     self.question = RestaurantQuestion.objects.create(
         user=self.dummy_user,
         restaurant=self.restaurant,
         question="Test question",
     )
コード例 #7
0
 def test_question_related_name(self):
     restaurant = create_restaurant(
         restaurant_name="JUST SALAD",
         business_address="252 7th Ave",
         yelp_detail=None,
         postcode="11215",
         business_id="kasdjf09j2oijlkdjsf",
     )
     RestaurantQuestion.objects.create(user=self.dummy_user,
                                       restaurant=restaurant,
                                       question="Test question??")
     user_questions = self.dummy_user.questions.first()
     restaurant_questions = restaurant.questions.first()
     self.assertEqual(user_questions.question, "Test question??")
     self.assertEqual(restaurant_questions.question, "Test question??")
コード例 #8
0
 def test_answers_related_name(self):
     restaurant = create_restaurant(
         restaurant_name="JUST SALAD",
         business_address="252 7th Ave",
         yelp_detail=None,
         postcode="11215",
         business_id="kasdjf09j2oijlkdjsf",
     )
     q1 = RestaurantQuestion.objects.create(user=self.dummy_user,
                                            restaurant=restaurant,
                                            question="Test question??")
     RestaurantAnswer.objects.create(user=self.dummy_user,
                                     question=q1,
                                     text="test answer!!")
     user_answers = self.dummy_user.answers.first()
     question_answers = q1.answers.first()
     self.assertEqual(user_answers.text, "test answer!!")
     self.assertEqual(question_answers.text, "test answer!!")
コード例 #9
0
    def setUp(self):
        self.c = Client()
        # Initialize 2 test users & 1 admin
        self.user1 = get_user_model().objects.create(
            username="******",
            email="*****@*****.**",
        )
        self.user1.set_password("test1234Report")
        self.user1.save()

        self.admin = get_user_model().objects.create(
            username="******",
            email="*****@*****.**",
        )
        self.admin.set_password("test1234Admin")
        self.admin.is_superuser = True
        self.admin.is_staff = True
        self.admin.save()

        # Initialize temp restaurant
        self.temp_restaurant = create_restaurant(
            restaurant_name="Tacos El Paisa",
            business_address=
            "1548 St. Nicholas btw West 187th street and west 188th "
            "street, Manhattan, NY",
            yelp_detail=None,
            postcode="10040",
            business_id="WavvLdfdP6g8aZTtbBQHTw",
        )
        self.temp_restaurant.save()

        # Initialize temp review
        self.temp_review = create_review(
            self.user1,
            self.temp_restaurant,
            "review for tests",
            5,
        )
        self.temp_review.save()

        # Initialize temp comment
        self.temp_comment = create_comment(
            self.user1, self.temp_review, "comment for test report functions")
        self.temp_comment.save()