def test_ManyToMany_of_category_representation(self): ''' ManyToMany of category in Food models is relete on field of Category ''' category1 = Category(type_name='Rice') category1.save() category2 = Category(type_name='Healthy') category2.save() ethnic_food = EthnicFood(ethnic_food_name='ThaiFood') ethnic_food.save() food = Food(food_name='Jok', ethnic_food_name=ethnic_food) food.save() food.category.add(category1) food.category.add(category2) self.assertEqual(list(food.category.all()), [category1, category2])
def test_objects_of_ethnic_food_name_representation(self): ''' ForeignKey of ethnic_food_name in Food models is equal to ethnic_Food ''' ethnic_food = EthnicFood(ethnic_food_name='JapanFood') text = Food(ethnic_food_name=ethnic_food) self.assertEqual(Food.get_ethnic_food_name(text), text.ethnic_food_name)
def test_intenger_of_user_rate_representation(self): ''' DecimalField of user_rate Food models is equal to number ''' number = Food(user_rate=10) self.assertEqual(Food.get_user_rate(number), number.user_rate)
def test_intenger_of_average_price_representation(self): ''' DecimalField of average_price in Food models is equal to baht ''' baht = Food(average_price=10) self.assertEqual(Food.get_average_price(baht), baht.average_price)
def test_string_of_image_location_representation(self): ''' Charfield of image_location in Food models is equal to text ''' text = Food(image_location='/home/test') self.assertEqual(Food.get_image_location(text), text.image_location)
def test_string_of_food_name_representation(self): ''' Charfield of food_name in Food models is equal to name ''' name = Food(food_name='Jok') self.assertEqual(str(name), name.food_name)