How to use third_test method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

test.py

Source:test.py Github

copy

Full Screen

1"""2File of test3"""4import unittest5import json6import requests_mock7from blog_post import app8class TestBlogPostRoutes(unittest.TestCase):9 """10 Class of test blog post routes11 """12 def setUp(self):13 """14 Setup environment for tests15 """16 self.application = app.test_client()17 self.post_mock_tag_test = {"posts": [18 {19 "author": "Test Author",20 "authorId": 999,21 "id": 1,22 "likes": 9999,23 "popularity": 1.0,24 "reads": 9999,25 "tags": [26 "test",27 ]28 }, {29 "author": "Test Author",30 "authorId": 999,31 "id": 4,32 "likes": 999,33 "popularity": 0.99,34 "reads": 9999,35 "tags": [36 "test", "second_test"37 ]38 }, {39 "author": "Test Author",40 "authorId": 999,41 "id": 5,42 "likes": 999,43 "popularity": 0.99,44 "reads": 9999,45 "tags": [46 "test", "third_test"47 ]48 },49 {50 "author": "Test Author",51 "authorId": 999,52 "id": 6,53 "likes": 999,54 "popularity": 0.99,55 "reads": 9999,56 "tags": [57 "test", "second_test", "third_test"58 ]59 }60 ]}61 self.post_mock_tag_second_test = {"posts": [62 {63 "author": "Test Author",64 "authorId": 999,65 "id": 2,66 "likes": 10,67 "popularity": 0.1,68 "reads": 10,69 "tags": [70 "second_test",71 ]72 },73 {74 "author": "Test Author",75 "authorId": 999,76 "id": 4,77 "likes": 999,78 "popularity": 0.99,79 "reads": 9999,80 "tags": [81 "test", "second_test"82 ]83 },84 {85 "author": "Test Author",86 "authorId": 999,87 "id": 6,88 "likes": 999,89 "popularity": 0.99,90 "reads": 9999,91 "tags": [92 "test", "second_test", "third_test"93 ]94 }95 ]}96 self.post_mock_tag_third_test = {"posts": [97 {98 "author": "Test Author",99 "authorId": 999,100 "id": 3,101 "likes": 500,102 "popularity": 0.5,103 "reads": 500,104 "tags": [105 "third_test",106 ]107 },108 {109 "author": "Test Author",110 "authorId": 999,111 "id": 5,112 "likes": 999,113 "popularity": 0.99,114 "reads": 9999,115 "tags": [116 "test", "third_test"117 ]118 },119 {120 "author": "Test Author",121 "authorId": 999,122 "id": 6,123 "likes": 999,124 "popularity": 0.99,125 "reads": 9999,126 "tags": [127 "test", "second_test", "third_test"128 ]129 }130 ]}131 def test_ping(self):132 """133 Test Ping route134 """135 ans = self.application.get("/api/ping")136 response = json.loads(ans.data)137 self.assertEqual(ans.status_code, 200)138 self.assertTrue(response.get('success'), True)139 def test_blog_posts_invalid_direction(self):140 """141 Test invalid direction parameter142 """143 ans = self.application.get("/api/posts?tags=tech&direction=ascending")144 self.assertEqual(ans.status_code, 400)145 def test_blog_posts_invalid_sortBy(self):146 """147 Test invalid sortBy parameter148 """149 ans = self.application.get("/api/posts?tags=tech&sortBy=authorId")150 self.assertEqual(ans.status_code, 400)151 def test_blog_posts_without_tag(self):152 """153 Test invalid tag parameter154 """155 ans = self.application.get("/api/posts")156 self.assertEqual(ans.status_code, 400)157 @requests_mock.Mocker(kw='mock')158 def test_blog_posts_one_tag(self, **kwargs):159 """160 Test request posts with one tag161 """162 kwargs['mock'].get('https://api.hatchways.io/assessment/blog/posts?tag=test',163 text=json.dumps(self.post_mock_tag_test), status_code=200)164 ans = self.application.get("/api/posts?tags=test")165 response = json.loads(ans.data)166 self.assertEqual(ans.status_code, 200)167 self.assertEqual(len(response), 4)168 @requests_mock.Mocker(kw='mock')169 def test_blog_posts_more_than_one_tag(self, **kwargs):170 """171 Test request posts with more than one tag172 """173 kwargs['mock'].get('https://api.hatchways.io/assessment/blog/posts?tag=test',174 text=json.dumps(self.post_mock_tag_test), status_code=200)175 kwargs['mock'].get('https://api.hatchways.io/assessment/blog/posts?tag=second_test',176 text=json.dumps(self.post_mock_tag_second_test), status_code=200)177 kwargs['mock'].get('https://api.hatchways.io/assessment/blog/posts?tag=third_test',178 text=json.dumps(self.post_mock_tag_third_test), status_code=200)179 ans = self.application.get("/api/posts?tags=test,second_test,third_test")180 response = json.loads(ans.data)181 self.assertEqual(ans.status_code, 200)182 self.assertEqual(len(response), 6)183 @requests_mock.Mocker(kw='mock')184 def test_blog_posts_remove_duplicated(self, **kwargs):185 """186 Test request posts with duplicated values187 """188 kwargs['mock'].get('https://api.hatchways.io/assessment/blog/posts?tag=test',189 text=json.dumps(self.post_mock_tag_test), status_code=200)190 kwargs['mock'].get('https://api.hatchways.io/assessment/blog/posts?tag=second_test',191 text=json.dumps(self.post_mock_tag_second_test), status_code=200)192 ans = self.application.get("/api/posts?tags=test,second_test")193 response = json.loads(ans.data)194 self.assertEqual(ans.status_code, 200)195 self.assertEqual(len(response), 5)196 @requests_mock.Mocker(kw='mock')197 def test_blog_posts_direction_asc(self, **kwargs):198 """199 Test request posts direction ascending sort by id200 """201 kwargs['mock'].get('https://api.hatchways.io/assessment/blog/posts?tag=test',202 text=json.dumps(self.post_mock_tag_test), status_code=200)203 kwargs['mock'].get('https://api.hatchways.io/assessment/blog/posts?tag=second_test',204 text=json.dumps(self.post_mock_tag_second_test), status_code=200)205 kwargs['mock'].get('https://api.hatchways.io/assessment/blog/posts?tag=third_test',206 text=json.dumps(self.post_mock_tag_third_test), status_code=200)207 ans = self.application.get("/api/posts?tags=test,second_test,third_test")208 response = json.loads(ans.data)209 self.assertEqual(ans.status_code, 200)210 self.assertEqual(response[0]['id'], 1)211 @requests_mock.Mocker(kw='mock')212 def test_blog_posts_direction_desc(self, **kwargs):213 """214 Test request posts direction descending sort by id215 """216 kwargs['mock'].get('https://api.hatchways.io/assessment/blog/posts?tag=test',217 text=json.dumps(self.post_mock_tag_test), status_code=200)218 kwargs['mock'].get('https://api.hatchways.io/assessment/blog/posts?tag=second_test',219 text=json.dumps(self.post_mock_tag_second_test), status_code=200)220 kwargs['mock'].get('https://api.hatchways.io/assessment/blog/posts?tag=third_test',221 text=json.dumps(self.post_mock_tag_third_test), status_code=200)222 ans = self.application.get("/api/posts?tags=test,second_test,third_test&direction=desc")223 response = json.loads(ans.data)224 self.assertEqual(ans.status_code, 200)225 self.assertEqual(response[0]['id'], 6)226 @requests_mock.Mocker(kw='mock')227 def test_blog_posts_sortBy_reads(self, **kwargs):228 """229 Test request posts sort by reads230 """231 kwargs['mock'].get('https://api.hatchways.io/assessment/blog/posts?tag=test',232 text=json.dumps(self.post_mock_tag_test), status_code=200)233 kwargs['mock'].get('https://api.hatchways.io/assessment/blog/posts?tag=second_test',234 text=json.dumps(self.post_mock_tag_second_test), status_code=200)235 kwargs['mock'].get('https://api.hatchways.io/assessment/blog/posts?tag=third_test',236 text=json.dumps(self.post_mock_tag_third_test), status_code=200)237 ans = self.application.get("/api/posts?tags=test,second_test,third_test&sortBy=reads")238 response = json.loads(ans.data)239 self.assertEqual(ans.status_code, 200)240 self.assertEqual(response[0]['reads'], 10)241 @requests_mock.Mocker(kw='mock')242 def test_blog_posts_sortBy_likes(self, **kwargs):243 """244 Test request posts sort by likes245 """246 kwargs['mock'].get('https://api.hatchways.io/assessment/blog/posts?tag=test',247 text=json.dumps(self.post_mock_tag_test), status_code=200)248 kwargs['mock'].get('https://api.hatchways.io/assessment/blog/posts?tag=second_test',249 text=json.dumps(self.post_mock_tag_second_test), status_code=200)250 kwargs['mock'].get('https://api.hatchways.io/assessment/blog/posts?tag=third_test',251 text=json.dumps(self.post_mock_tag_third_test), status_code=200)252 ans = self.application.get("/api/posts?tags=test,second_test,third_test&sortBy=likes")253 response = json.loads(ans.data)254 self.assertEqual(ans.status_code, 200)255 self.assertEqual(response[0]['likes'], 10)256 @requests_mock.Mocker(kw='mock')257 def test_blog_posts_sortBy_popularity(self, **kwargs):258 """259 Test request posts sort by popularity260 """261 kwargs['mock'].get('https://api.hatchways.io/assessment/blog/posts?tag=test',262 text=json.dumps(self.post_mock_tag_test), status_code=200)263 kwargs['mock'].get('https://api.hatchways.io/assessment/blog/posts?tag=second_test',264 text=json.dumps(self.post_mock_tag_second_test), status_code=200)265 kwargs['mock'].get('https://api.hatchways.io/assessment/blog/posts?tag=third_test',266 text=json.dumps(self.post_mock_tag_third_test), status_code=200)267 ans = self.application.get("/api/posts?tags=test,second_test,third_test&sortBy=popularity")268 response = json.loads(ans.data)269 self.assertEqual(ans.status_code, 200)270 self.assertEqual(response[0]['popularity'], 0.1)271if __name__ == '__main__':...

Full Screen

Full Screen

Treasure Hunt.py

Source:Treasure Hunt.py Github

copy

Full Screen

1print('''2*******************************************************************************3 | | | |4 _________|________________.=""_;=.______________|_____________________|_______5| | ,-"_,="" `"=.| |6|___________________|__"=._o`"-._ `"=.______________|___________________7 | `"=._o`"=._ _`"=._ |8 _________|_____________________:=._o "=._."_.-="'"=.__________________|_______9| | __.--" , ; `"=._o." ,-"""-._ ". |10|___________________|_._" ,. .` ` `` , `"-._"-._ ". '__|___________________11 | |o`"=._` , "` `; .". , "-._"-._; ; |12 _________|___________| ;`-.o`"=._; ." ` '`."\` . "-._ /_______________|_______13| | |o; `"-.o`"=._`` '` " ,__.--o; |14|___________________|_| ; (#) `-.o `"=.`_.--"_o.-; ;___|___________________15____/______/______/___|o;._ " `".o|o_.--" ;o;____/______/______/____16/______/______/______/_"=._o--._ ; | ; ; ;/______/______/______/_17____/______/______/______/__"=._o--._ ;o|o; _._;o;____/______/______/____18/______/______/______/______/____"=._o._; | ;_.--"o.--"_/______/______/______/_19____/______/______/______/______/_____"=.o|o_.--""___/______/______/______/____20/______/______/______/______/______/______/______/______/______/______/_____ /21*******************************************************************************22''')23print("Welcome to Treasure Island.")24print("Your mission is to find the treasure.") 25name = input("What is your name?\n")26first_test = input("You are at a fork in the road. Would you like to go right or left?\n").lower()27if first_test == 'right':28 print("You fell into a hole. Game Over. You suck.")29elif first_test == 'left':30 print("You went the right way. You may continue on your journey.")31 second_test = input("You have reached a beach and see an island in the distance. Would you like to swim to the island or wait for a boat? Type 'swim' or 'wait'\n").lower()32 if second_test == 'swim':33 print("You were eaten by piranhas. Game Over. You suck.")34 elif second_test == 'wait':35 print("The boat came and you reached the island safely. You may continue on your journey.")36 third_test = input("You have reached a room with 3 different doors. If you choose poorly, you will die. If you choose correctly, you will find the treasure.\nChoose a door: yellow, red or blue.\n").lower()37 if third_test == 'red':38 print("You were burned alive by a demon. Game Over. You suck.")39 elif third_test == 'yellow':40 print(f"Congratulations, {name}! You found the treasure. You win!")41 elif third_test == 'blue':42 print("You were eaten alive by rabid dogs. Game Over. You suck.")43 else:44 print("You got stuck and starved to death. Game Over. You suck")...

Full Screen

Full Screen

main.py

Source:main.py Github

copy

Full Screen

1first_test = str(input())2second_test = str(input())3third_test = str(input())4if first_test == 'vertebrado':5 6 if second_test == 'ave':7 if third_test == 'carnivoro':8 print('aguia')9 if third_test == 'onivoro':10 print('pomba')11 12 if second_test == 'mamifero':13 if third_test == 'onivoro':14 print('homem')15 if third_test == 'herbivoro':16 print('vaca')17if first_test == 'invertebrado':18 19 if second_test == 'inseto':20 if third_test == 'hematofago':21 print('pulga')22 if third_test == 'herbivoro':23 print('lagarta')24 25 if second_test == 'anelideo':26 if third_test == 'hematofago':27 print('sanguessuga')28 if third_test == 'onivoro':...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Lemoncheesecake automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful