1 00:00:00,480 --> 00:00:03,480 foreign 2 00:00:08,280 --> 00:00:12,660 welcome back to our last talk before 3 00:00:10,260 --> 00:00:14,759 lunch I'm very excited to Welcome to the 4 00:00:12,660 --> 00:00:18,240 stage Jenny who is a software engineer 5 00:00:14,759 --> 00:00:21,600 at car Calabria and who is also an 6 00:00:18,240 --> 00:00:24,359 Outreach alumni of the December 2021 7 00:00:21,600 --> 00:00:25,680 cohort I'm incredibly excited to be 8 00:00:24,359 --> 00:00:28,019 hearing about testing asynchronous 9 00:00:25,680 --> 00:00:32,300 applications with fast API and Pi test 10 00:00:28,019 --> 00:00:32,300 Jenny take it away thank you 11 00:00:34,260 --> 00:00:38,940 good afternoon all uh I'm Jenny and I'm 12 00:00:37,020 --> 00:00:41,160 going to talk about testing asynchronous 13 00:00:38,940 --> 00:00:43,620 applications with fast API and Pi test 14 00:00:41,160 --> 00:00:45,120 today so before digging into the topic I 15 00:00:43,620 --> 00:00:48,780 would like to briefly introduce myself 16 00:00:45,120 --> 00:00:50,700 so I come from India and I work as a 17 00:00:48,780 --> 00:00:53,160 software engineer and an open source 18 00:00:50,700 --> 00:00:54,960 consultancy called collabra before 19 00:00:53,160 --> 00:00:57,239 joining collabora I was announced your 20 00:00:54,960 --> 00:00:59,699 intern so that's where I started my open 21 00:00:57,239 --> 00:01:01,379 source journey I was working in a 22 00:00:59,699 --> 00:01:02,039 conversa organization 23 00:01:01,379 --> 00:01:03,480 um 24 00:01:02,039 --> 00:01:05,400 and 25 00:01:03,480 --> 00:01:08,040 um I kept contributing to that project 26 00:01:05,400 --> 00:01:10,920 while being in collabora so now I'm a 27 00:01:08,040 --> 00:01:13,080 co-maintainer of one of the projects uh 28 00:01:10,920 --> 00:01:15,180 if I talk about my technical interest of 29 00:01:13,080 --> 00:01:17,939 course Python and Linux fascinates me a 30 00:01:15,180 --> 00:01:21,299 lot and apart from that I love dancing 31 00:01:17,939 --> 00:01:23,400 and I never miss a chance to dance if 32 00:01:21,299 --> 00:01:25,020 the organizers would have given me extra 33 00:01:23,400 --> 00:01:27,540 few minutes you would definitely see me 34 00:01:25,020 --> 00:01:30,299 around dancing on the stage 35 00:01:27,540 --> 00:01:32,820 uh so let's see uh these are the agendas 36 00:01:30,299 --> 00:01:35,820 of today's talk I'm going to present 37 00:01:32,820 --> 00:01:38,880 what is first API a brief introduction 38 00:01:35,820 --> 00:01:41,159 about what is asynchronous programming 39 00:01:38,880 --> 00:01:44,579 then we're gonna see uh how to write 40 00:01:41,159 --> 00:01:46,439 test for the synchronous code uh then 41 00:01:44,579 --> 00:01:49,320 I'm going to present a very interesting 42 00:01:46,439 --> 00:01:51,420 test examples uh from Kenosha API and 43 00:01:49,320 --> 00:01:54,840 that is a back-end from kernels sky so 44 00:01:51,420 --> 00:01:56,640 before going uh into that I would uh 45 00:01:54,840 --> 00:01:57,960 briefly introduce what the project is 46 00:01:56,640 --> 00:02:01,200 about 47 00:01:57,960 --> 00:02:04,140 and then um yeah we'll see something uh 48 00:02:01,200 --> 00:02:07,439 some fast API in the practice 49 00:02:04,140 --> 00:02:09,300 so okay uh first of all what is fast API 50 00:02:07,439 --> 00:02:11,280 um as we all know python provides a 51 00:02:09,300 --> 00:02:14,940 variety of web Frameworks including 52 00:02:11,280 --> 00:02:16,680 Django and flask so fast API is one of 53 00:02:14,940 --> 00:02:20,400 the framework and what is special thing 54 00:02:16,680 --> 00:02:22,260 about is is it is the statistics in 55 00:02:20,400 --> 00:02:25,140 Benchmark shows that it is one of the 56 00:02:22,260 --> 00:02:28,440 fastest Frameworks available 57 00:02:25,140 --> 00:02:30,840 first API supports python 3.7 version 58 00:02:28,440 --> 00:02:34,319 and newer than that 59 00:02:30,840 --> 00:02:37,140 first API is based on Starlet and by 60 00:02:34,319 --> 00:02:39,599 dantec those are two different packages 61 00:02:37,140 --> 00:02:41,700 so uh for the people who don't know our 62 00:02:39,599 --> 00:02:44,220 Starlet is a package that is specially 63 00:02:41,700 --> 00:02:46,980 designed for writing the asynchronous 64 00:02:44,220 --> 00:02:50,519 web services and you can see that first 65 00:02:46,980 --> 00:02:53,160 DPR is a subclass of Starlet so it 66 00:02:50,519 --> 00:02:55,260 directly supports all the features that 67 00:02:53,160 --> 00:02:58,500 Starlet provides for example websockets 68 00:02:55,260 --> 00:03:00,660 bought then background tasks then events 69 00:02:58,500 --> 00:03:02,099 even handlers like startup and shutdown 70 00:03:00,660 --> 00:03:05,819 events 71 00:03:02,099 --> 00:03:08,040 it also has some inbuilt security 72 00:03:05,819 --> 00:03:10,620 utilities and dependency interactions as 73 00:03:08,040 --> 00:03:12,599 well now what is patient python Tech is 74 00:03:10,620 --> 00:03:15,900 a data validation package provided by 75 00:03:12,599 --> 00:03:18,540 python it works uh based on type ends so 76 00:03:15,900 --> 00:03:21,180 it has a by default validators and it 77 00:03:18,540 --> 00:03:23,819 can be useful to validate your request 78 00:03:21,180 --> 00:03:26,159 and response parameters so it is pretty 79 00:03:23,819 --> 00:03:27,900 useful you don't need to do everything 80 00:03:26,159 --> 00:03:31,200 manually 81 00:03:27,900 --> 00:03:33,900 apart from that first API provides 82 00:03:31,200 --> 00:03:36,540 automatic interactive documentation it 83 00:03:33,900 --> 00:03:39,300 is based on open EI and you can have 84 00:03:36,540 --> 00:03:42,060 either speaker paste documentation or 85 00:03:39,300 --> 00:03:44,519 retalk generated documentation it is 86 00:03:42,060 --> 00:03:46,620 pretty interactive so you that you can 87 00:03:44,519 --> 00:03:48,780 test your client application from the 88 00:03:46,620 --> 00:03:51,840 browser itself so these were the 89 00:03:48,780 --> 00:03:54,120 features of fast API now we'll see what 90 00:03:51,840 --> 00:03:57,720 is the synchronous programming 91 00:03:54,120 --> 00:04:01,080 so um programming Paradigm can be a 92 00:03:57,720 --> 00:04:03,000 defined with the two kind of Paradigm 93 00:04:01,080 --> 00:04:05,280 one is the synchronous and another one 94 00:04:03,000 --> 00:04:07,379 is asynchronous so when multiple 95 00:04:05,280 --> 00:04:09,120 processes are there and all the 96 00:04:07,379 --> 00:04:10,799 processes are running sequentially like 97 00:04:09,120 --> 00:04:13,200 one by one that is called the 98 00:04:10,799 --> 00:04:15,000 synchronous programming right and when 99 00:04:13,200 --> 00:04:17,820 multiple processes are there and they 100 00:04:15,000 --> 00:04:19,680 can run at the same time of course not 101 00:04:17,820 --> 00:04:22,019 like it is not necessary that they are 102 00:04:19,680 --> 00:04:24,120 running simultaneously but if they are 103 00:04:22,019 --> 00:04:25,620 running in overlapping manner as well so 104 00:04:24,120 --> 00:04:28,620 you can see that that is asynchronous 105 00:04:25,620 --> 00:04:30,720 programming and what is the special 106 00:04:28,620 --> 00:04:33,960 thing about asynchronous programming is 107 00:04:30,720 --> 00:04:35,880 it has the ability to wait for a task to 108 00:04:33,960 --> 00:04:38,160 complete and do something else in the 109 00:04:35,880 --> 00:04:40,199 meantime so we'll explain this in a very 110 00:04:38,160 --> 00:04:42,960 uh simple example 111 00:04:40,199 --> 00:04:46,259 so I have um attached to pictures here 112 00:04:42,960 --> 00:04:48,900 the first thing the first picture shows 113 00:04:46,259 --> 00:04:50,880 that a very long queue of the people so 114 00:04:48,900 --> 00:04:53,040 imagine that you are visiting a museum 115 00:04:50,880 --> 00:04:56,100 in Adelaide you have already bought a 116 00:04:53,040 --> 00:04:57,840 ticket now you are in a queue and you're 117 00:04:56,100 --> 00:04:59,160 waiting for your turn to come up to 118 00:04:57,840 --> 00:05:02,040 enter the museum 119 00:04:59,160 --> 00:05:03,840 so um if you imagine that every single 120 00:05:02,040 --> 00:05:07,680 people in the queue is every single 121 00:05:03,840 --> 00:05:10,500 process then they can execute just after 122 00:05:07,680 --> 00:05:12,600 the prior one completes like for example 123 00:05:10,500 --> 00:05:14,340 if the first one first person goes in 124 00:05:12,600 --> 00:05:16,979 then and then the only the second person 125 00:05:14,340 --> 00:05:18,600 can goes in so that is the example of 126 00:05:16,979 --> 00:05:20,220 synchronous programming and while 127 00:05:18,600 --> 00:05:23,039 waiting in the queue they cannot do 128 00:05:20,220 --> 00:05:24,840 anything else but just waiting right so 129 00:05:23,039 --> 00:05:27,060 that is an example of synchronous now 130 00:05:24,840 --> 00:05:28,620 another picture is about restaurant so 131 00:05:27,060 --> 00:05:30,419 there are multiple tables and multiple 132 00:05:28,620 --> 00:05:32,460 group of people are there 133 00:05:30,419 --> 00:05:34,139 if you imagine every single group of 134 00:05:32,460 --> 00:05:36,240 people as a separate process they can 135 00:05:34,139 --> 00:05:37,800 order food at like at the same time of 136 00:05:36,240 --> 00:05:40,259 course not simultilies but they can do 137 00:05:37,800 --> 00:05:42,180 that at the same time and while waiting 138 00:05:40,259 --> 00:05:44,220 for the food to get delivered they can 139 00:05:42,180 --> 00:05:46,500 have a chat with each other or scroll 140 00:05:44,220 --> 00:05:48,180 their phone or do anything else they 141 00:05:46,500 --> 00:05:51,419 want so that is the ability of 142 00:05:48,180 --> 00:05:54,120 asynchronous code so that they can do 143 00:05:51,419 --> 00:05:55,800 like simultaneous thing well we well 144 00:05:54,120 --> 00:05:57,180 they are waiting for a particular thing 145 00:05:55,800 --> 00:05:58,380 to happen 146 00:05:57,180 --> 00:06:01,860 okay 147 00:05:58,380 --> 00:06:04,740 now uh how to write asynchronous code 148 00:06:01,860 --> 00:06:07,860 with a fast API so first API is based on 149 00:06:04,740 --> 00:06:09,539 any i o package the Nar package is in a 150 00:06:07,860 --> 00:06:12,720 tool or you can see framework to write 151 00:06:09,539 --> 00:06:15,180 asynchronous networking apps so fast API 152 00:06:12,720 --> 00:06:17,340 supports that first API also supports 153 00:06:15,180 --> 00:06:19,860 this two backends called async IO and 154 00:06:17,340 --> 00:06:21,600 Trio packages so you can use any of this 155 00:06:19,860 --> 00:06:24,720 package to write your asynchronous code 156 00:06:21,600 --> 00:06:26,580 with a fast API moreover python has the 157 00:06:24,720 --> 00:06:29,280 modern versions of python has introduced 158 00:06:26,580 --> 00:06:31,199 functions called Cod routines so it is 159 00:06:29,280 --> 00:06:33,240 just a fancy word about the asynchronous 160 00:06:31,199 --> 00:06:35,280 function so when you have async and 161 00:06:33,240 --> 00:06:36,419 await keywords with your functions then 162 00:06:35,280 --> 00:06:38,280 you can say that this is the 163 00:06:36,419 --> 00:06:40,800 asynchronous functions 164 00:06:38,280 --> 00:06:43,380 here is a pseudo code so I'm trying to 165 00:06:40,800 --> 00:06:45,419 get some documents from my database so I 166 00:06:43,380 --> 00:06:48,000 have defined that function as 167 00:06:45,419 --> 00:06:50,819 asynchronous so I've done that by using 168 00:06:48,000 --> 00:06:52,319 this keyword that is async Def so it 169 00:06:50,819 --> 00:06:55,740 will know that this is the asynchronous 170 00:06:52,319 --> 00:06:57,780 function and um while the database go 171 00:06:55,740 --> 00:07:00,780 and fetches documents from the database 172 00:06:57,780 --> 00:07:02,400 I will wait to get the documents so I 173 00:07:00,780 --> 00:07:06,300 have done that by using the await 174 00:07:02,400 --> 00:07:09,240 keyboard so await will wait for the 175 00:07:06,300 --> 00:07:10,740 response to get right so and I'm simply 176 00:07:09,240 --> 00:07:12,900 returning the documents from the 177 00:07:10,740 --> 00:07:15,180 function so this is a very basic suit 178 00:07:12,900 --> 00:07:18,020 example of finishing Chrome is code that 179 00:07:15,180 --> 00:07:20,819 you can write for the first API 180 00:07:18,020 --> 00:07:24,000 uh now I'm going to discuss like few 181 00:07:20,819 --> 00:07:26,099 bullet points about how I write a test 182 00:07:24,000 --> 00:07:28,080 for the asynchronous code this is not 183 00:07:26,099 --> 00:07:30,240 like official documentation or any 184 00:07:28,080 --> 00:07:33,660 standard things but this is the uh 185 00:07:30,240 --> 00:07:35,039 somebody that I find helpful for myself 186 00:07:33,660 --> 00:07:37,080 so first 187 00:07:35,039 --> 00:07:39,240 um if you are writing a test case then 188 00:07:37,080 --> 00:07:41,460 you will need a test client so for the 189 00:07:39,240 --> 00:07:45,419 synchronous test cases it provides a 190 00:07:41,460 --> 00:07:47,099 test client called it it by default it 191 00:07:45,419 --> 00:07:50,520 has the test client so you can use for 192 00:07:47,099 --> 00:07:53,160 the first API for the asynchronous we 193 00:07:50,520 --> 00:07:55,139 will be using https library that is the 194 00:07:53,160 --> 00:07:57,720 another library for HTTP handlers from 195 00:07:55,139 --> 00:08:00,060 python so you can use asynchronous test 196 00:07:57,720 --> 00:08:03,180 plan from that Library 197 00:08:00,060 --> 00:08:06,240 after that we will be going to use some 198 00:08:03,180 --> 00:08:08,699 of the pi test fixtures so when you are 199 00:08:06,240 --> 00:08:10,919 writing a test case for some kind of a 200 00:08:08,699 --> 00:08:13,979 specific scenario that that will be case 201 00:08:10,919 --> 00:08:16,259 that you will need to have some data fed 202 00:08:13,979 --> 00:08:18,000 into your test case for example if you 203 00:08:16,259 --> 00:08:20,340 need to initialize your application if 204 00:08:18,000 --> 00:08:22,979 you want to setting things up if you 205 00:08:20,340 --> 00:08:24,840 want to set your database or any kind of 206 00:08:22,979 --> 00:08:26,460 service setup then you will need those 207 00:08:24,840 --> 00:08:29,580 kind of information before you actually 208 00:08:26,460 --> 00:08:32,279 run your test so those kind of functions 209 00:08:29,580 --> 00:08:34,380 and utilities you can write as a pie 210 00:08:32,279 --> 00:08:37,560 test fixtures and then you can use it 211 00:08:34,380 --> 00:08:39,300 directly from your byte from the from a 212 00:08:37,560 --> 00:08:42,839 test case 213 00:08:39,300 --> 00:08:44,820 okay uh if I am writing a unit test if 214 00:08:42,839 --> 00:08:46,560 my application has multiple components 215 00:08:44,820 --> 00:08:49,260 and multiple modules in my application 216 00:08:46,560 --> 00:08:51,360 so in the unit test what we do is we 217 00:08:49,260 --> 00:08:53,279 just focus on a single separate 218 00:08:51,360 --> 00:08:56,100 component and we write test cases for 219 00:08:53,279 --> 00:08:58,680 that if I have application and some of 220 00:08:56,100 --> 00:09:00,300 these API services that I'm using for 221 00:08:58,680 --> 00:09:02,220 example if I'm using database service 222 00:09:00,300 --> 00:09:04,500 rate is service or any other kind of 223 00:09:02,220 --> 00:09:07,080 service but I just want to focus on a 224 00:09:04,500 --> 00:09:09,300 single component API then if my 225 00:09:07,080 --> 00:09:11,580 application is communicating with this 226 00:09:09,300 --> 00:09:13,140 other modules then I need to mock some 227 00:09:11,580 --> 00:09:16,200 function calls when I'm writing unit 228 00:09:13,140 --> 00:09:18,000 test because we are just focusing on 229 00:09:16,200 --> 00:09:20,040 single module and will be not having 230 00:09:18,000 --> 00:09:22,440 those Services up and running so the 231 00:09:20,040 --> 00:09:25,140 communication won't be able to happen 232 00:09:22,440 --> 00:09:28,380 so in this kind of scenarios we need to 233 00:09:25,140 --> 00:09:30,779 mock function calls where we require 234 00:09:28,380 --> 00:09:32,580 then of course actually uh write your 235 00:09:30,779 --> 00:09:35,160 test function the actual test function 236 00:09:32,580 --> 00:09:37,500 then you need to Define what the test 237 00:09:35,160 --> 00:09:39,300 what kind of test environment uh you 238 00:09:37,500 --> 00:09:41,279 would like to run and then of course run 239 00:09:39,300 --> 00:09:44,399 your test 240 00:09:41,279 --> 00:09:46,920 okay uh so I'm going to uh describe some 241 00:09:44,399 --> 00:09:48,779 of the test examples from karnesia API 242 00:09:46,920 --> 00:09:50,820 but before that I would like to 243 00:09:48,779 --> 00:09:54,839 introduce this project uh this is called 244 00:09:50,820 --> 00:09:56,940 karna CI so as we all know Linux kernel 245 00:09:54,839 --> 00:09:58,980 is running on variety of Hardwares and 246 00:09:56,940 --> 00:10:01,140 devices right so it will be very 247 00:09:58,980 --> 00:10:04,620 difficult to maintain its stability and 248 00:10:01,140 --> 00:10:07,620 quality around this range of Hardware so 249 00:10:04,620 --> 00:10:10,140 in 2014 a Linux kernel a few Linux 250 00:10:07,620 --> 00:10:14,100 kernel developers and a few uh community 251 00:10:10,140 --> 00:10:17,279 members from Community decided to have a 252 00:10:14,100 --> 00:10:19,260 specific CS system for Linux kernel 253 00:10:17,279 --> 00:10:21,420 that's where this project got started 254 00:10:19,260 --> 00:10:25,320 and now it is a Linux Foundation project 255 00:10:21,420 --> 00:10:27,959 so basically Linux kernel uh Kenosha is 256 00:10:25,320 --> 00:10:29,880 in shorting the quality stability and 257 00:10:27,959 --> 00:10:31,860 long-term maintenance of Linux kernel 258 00:10:29,880 --> 00:10:34,140 since simpler was what you can do with 259 00:10:31,860 --> 00:10:36,300 Garcia is if you have your specific 260 00:10:34,140 --> 00:10:39,180 Linux kernel then you can build your 261 00:10:36,300 --> 00:10:42,540 Linux kernel with Canon CI tools then 262 00:10:39,180 --> 00:10:44,399 you can have a set of tests on the on 263 00:10:42,540 --> 00:10:46,920 your kernel and then you can also submit 264 00:10:44,399 --> 00:10:49,440 your test to a common database tool and 265 00:10:46,920 --> 00:10:51,360 that will be accessible by publicly 266 00:10:49,440 --> 00:10:52,980 so you could have your test reports 267 00:10:51,360 --> 00:10:55,380 regression reports even by section 268 00:10:52,980 --> 00:10:57,540 reports with Gunner CI if you are more 269 00:10:55,380 --> 00:11:00,240 interested then I have mentioned a link 270 00:10:57,540 --> 00:11:03,600 there kenosha.org you can go and check 271 00:11:00,240 --> 00:11:06,120 out the project in detail and the reason 272 00:11:03,600 --> 00:11:07,740 I'm discussing kernel CI here is a 273 00:11:06,120 --> 00:11:11,279 conversion has a new backend called 274 00:11:07,740 --> 00:11:14,940 karnesia API and kernelsia API is based 275 00:11:11,279 --> 00:11:17,820 on these uh major building blocks it it 276 00:11:14,940 --> 00:11:19,440 um it is built on top of fast API so 277 00:11:17,820 --> 00:11:22,440 that was the reason I'm discussing this 278 00:11:19,440 --> 00:11:25,500 project for the database it uses mongodb 279 00:11:22,440 --> 00:11:28,560 and that it is an in-memory database 280 00:11:25,500 --> 00:11:31,800 and it also has a storage support you 281 00:11:28,560 --> 00:11:34,260 can use as SSH for the upload and HTTP 282 00:11:31,800 --> 00:11:35,940 for download so that uh this I'm not 283 00:11:34,260 --> 00:11:39,180 going into detail because this is out of 284 00:11:35,940 --> 00:11:42,000 scope for this uh talk but everything is 285 00:11:39,180 --> 00:11:44,640 up um publicly on GitHub if you want to 286 00:11:42,000 --> 00:11:47,360 access this project you can go with this 287 00:11:44,640 --> 00:11:49,800 you can go on this get up link and find 288 00:11:47,360 --> 00:11:53,220 API project 289 00:11:49,800 --> 00:11:55,260 now let's dig into the text examples so 290 00:11:53,220 --> 00:11:57,060 first I am going to describe the unit 291 00:11:55,260 --> 00:11:58,920 Test example 292 00:11:57,060 --> 00:12:01,680 um so 293 00:11:58,920 --> 00:12:02,940 API has a root Handler a root Handler of 294 00:12:01,680 --> 00:12:05,040 course we all know that that is the 295 00:12:02,940 --> 00:12:07,560 entry point or initialization point for 296 00:12:05,040 --> 00:12:11,399 any application so in case of currency 297 00:12:07,560 --> 00:12:13,440 API it returns this dictionary uh with a 298 00:12:11,399 --> 00:12:16,260 message as a queue and currency API is 299 00:12:13,440 --> 00:12:18,779 as a value it is a pretty uh basic 300 00:12:16,260 --> 00:12:21,600 endpoint the root and the one so if you 301 00:12:18,779 --> 00:12:25,800 send the HTTP get request to this root 302 00:12:21,600 --> 00:12:27,839 endpoint it will be uh this it will be 303 00:12:25,800 --> 00:12:30,180 providing this response 304 00:12:27,839 --> 00:12:34,320 now how to write test of this kind of 305 00:12:30,180 --> 00:12:36,540 endpoint so as we saw uh as we saw that 306 00:12:34,320 --> 00:12:39,899 we need to have some kind of test client 307 00:12:36,540 --> 00:12:43,139 to write the test for it so I have used 308 00:12:39,899 --> 00:12:45,540 uh fast api.test client package to use 309 00:12:43,139 --> 00:12:47,700 the synchronous test client so if you 310 00:12:45,540 --> 00:12:50,339 see the first frame I have shown in the 311 00:12:47,700 --> 00:12:52,380 snapshot is I am creating an instance of 312 00:12:50,339 --> 00:12:55,320 the test client it will need two 313 00:12:52,380 --> 00:12:59,339 arguments one is a application instance 314 00:12:55,320 --> 00:13:01,920 and another one is URL of API server so 315 00:12:59,339 --> 00:13:04,320 in the unit test we are not going to run 316 00:13:01,920 --> 00:13:07,560 any kind of server the actual server so 317 00:13:04,320 --> 00:13:09,899 what we can do is we can use the demo 318 00:13:07,560 --> 00:13:12,899 server or fake server provided by fast 319 00:13:09,899 --> 00:13:15,480 API so this is the default server that 320 00:13:12,899 --> 00:13:17,519 is HTTP test server and I'm going to use 321 00:13:15,480 --> 00:13:21,480 it in my test case 322 00:13:17,519 --> 00:13:23,820 please note that I have written it as a 323 00:13:21,480 --> 00:13:25,860 form of Pi test fixture because test 324 00:13:23,820 --> 00:13:28,920 client is something that will be knit 325 00:13:25,860 --> 00:13:30,899 needed to fit with every test cases that 326 00:13:28,920 --> 00:13:33,360 I write okay so I would need that for 327 00:13:30,899 --> 00:13:36,180 the initialization so I have chosen it 328 00:13:33,360 --> 00:13:38,700 to uh to be as a pi test fixture 329 00:13:36,180 --> 00:13:40,920 and another function is test root 330 00:13:38,700 --> 00:13:43,920 endpoint this is the actual test case of 331 00:13:40,920 --> 00:13:46,440 my unit test so what I'm doing is I'm 332 00:13:43,920 --> 00:13:48,180 passing the test client the fixture name 333 00:13:46,440 --> 00:13:51,000 in the argument so that is the way of 334 00:13:48,180 --> 00:13:52,560 using pi test fixture you just uh need 335 00:13:51,000 --> 00:13:54,420 to pass it in the argument and it will 336 00:13:52,560 --> 00:13:56,040 be executed before actual test case 337 00:13:54,420 --> 00:13:58,740 executes 338 00:13:56,040 --> 00:14:01,500 so what I'm doing is I am sending HTTP 339 00:13:58,740 --> 00:14:03,420 get request using that test client with 340 00:14:01,500 --> 00:14:06,300 test client.get method and I'll be 341 00:14:03,420 --> 00:14:09,000 receiving some HTTP response we can use 342 00:14:06,300 --> 00:14:12,720 uh some asset statements to verify what 343 00:14:09,000 --> 00:14:15,720 your test has received as a response so 344 00:14:12,720 --> 00:14:17,600 you can I I have used this asset the the 345 00:14:15,720 --> 00:14:20,880 last frame of the snapshot that I said 346 00:14:17,600 --> 00:14:22,860 response dot status code equal to 200 so 347 00:14:20,880 --> 00:14:26,100 if this condition fails it will raise 348 00:14:22,860 --> 00:14:27,120 the session and a error and my test will 349 00:14:26,100 --> 00:14:30,240 fail 350 00:14:27,120 --> 00:14:31,620 okay so let's try to run a test of 351 00:14:30,240 --> 00:14:33,240 course there are variety of testing 352 00:14:31,620 --> 00:14:35,040 environments that you can use but I have 353 00:14:33,240 --> 00:14:37,079 chosen the very basic one and this is 354 00:14:35,040 --> 00:14:39,420 the command line utility so I'm running 355 00:14:37,079 --> 00:14:42,360 Pi test commands on the command line to 356 00:14:39,420 --> 00:14:46,500 run my test so let's see how it goes 357 00:14:42,360 --> 00:14:48,540 oh and the test got failed why so in the 358 00:14:46,500 --> 00:14:50,399 snapshot I have shared that these These 359 00:14:48,540 --> 00:14:52,620 are the error logs that I've received 360 00:14:50,399 --> 00:14:55,079 and it shows that there is some some 361 00:14:52,620 --> 00:14:57,000 kind of startup Handler is there and it 362 00:14:55,079 --> 00:15:00,540 is trying to connect one method called 363 00:14:57,000 --> 00:15:02,519 Pub sub.create and again uh the last 364 00:15:00,540 --> 00:15:04,500 line of the frame shows that it is 365 00:15:02,519 --> 00:15:06,959 trying to connect with some method 366 00:15:04,500 --> 00:15:10,040 called Pub subtitude in its sub ID 367 00:15:06,959 --> 00:15:13,620 so under the hood what happened is Now 368 00:15:10,040 --> 00:15:16,440 API is uh has published a subscriber 369 00:15:13,620 --> 00:15:19,019 mechanism implemented so it is using 370 00:15:16,440 --> 00:15:22,019 some kind of tool called redis so red is 371 00:15:19,019 --> 00:15:24,000 a in-memory database uh tool so so you 372 00:15:22,019 --> 00:15:27,120 can use it for your pop sub mechanisms 373 00:15:24,000 --> 00:15:30,060 so under the hood karna CI API is trying 374 00:15:27,120 --> 00:15:32,639 to connect with the treaty server on its 375 00:15:30,060 --> 00:15:34,260 initialization but it is not trying to 376 00:15:32,639 --> 00:15:36,839 connect like it is trying to money but 377 00:15:34,260 --> 00:15:39,300 it got failed of course this is expected 378 00:15:36,839 --> 00:15:42,120 outcome because we are not running any 379 00:15:39,300 --> 00:15:43,980 redness server with our test right 380 00:15:42,120 --> 00:15:46,500 so how do you deal with this kind of 381 00:15:43,980 --> 00:15:49,079 situation so I've also mentioned that 382 00:15:46,500 --> 00:15:52,320 you you can mock function calls whenever 383 00:15:49,079 --> 00:15:55,440 you need it so what you will do is 384 00:15:52,320 --> 00:15:58,019 you'll need you'll have a mock function 385 00:15:55,440 --> 00:16:00,540 called to your method called Pub sub.net 386 00:15:58,019 --> 00:16:03,060 sub ID so there is a package called Unit 387 00:16:00,540 --> 00:16:04,920 unit test from the python 388 00:16:03,060 --> 00:16:06,959 and if you are writing tests for the 389 00:16:04,920 --> 00:16:10,260 asynchronous functions and you want to 390 00:16:06,959 --> 00:16:12,540 mock that function call you you can use 391 00:16:10,260 --> 00:16:14,639 the specific async mock from the unit 392 00:16:12,540 --> 00:16:17,760 test package 393 00:16:14,639 --> 00:16:20,459 okay and uh though this the first frame 394 00:16:17,760 --> 00:16:24,120 I have drawn here is 395 00:16:20,459 --> 00:16:27,180 it is uh it it has created one async 396 00:16:24,120 --> 00:16:30,060 mock object and the another line says 397 00:16:27,180 --> 00:16:33,839 that mocker.patch it is used to patch 398 00:16:30,060 --> 00:16:36,660 your class level methods or even modules 399 00:16:33,839 --> 00:16:38,880 to patch that particular function with 400 00:16:36,660 --> 00:16:40,860 the mock object that you have created so 401 00:16:38,880 --> 00:16:43,680 with the async mock I have mocked the 402 00:16:40,860 --> 00:16:47,579 function call that is popsup.net ID so 403 00:16:43,680 --> 00:16:49,860 what now uh will happen is when uh when 404 00:16:47,579 --> 00:16:52,079 the pop sub dot init sub ID method gets 405 00:16:49,860 --> 00:16:53,820 called instead of calling that specific 406 00:16:52,079 --> 00:16:56,699 method it will go straight to the 407 00:16:53,820 --> 00:16:58,920 asynchronous mock object so nothing will 408 00:16:56,699 --> 00:17:01,800 break in this case so I have defined 409 00:16:58,920 --> 00:17:04,559 this as a pi test fixture as well so I 410 00:17:01,800 --> 00:17:05,880 am passing the name of the fixture in in 411 00:17:04,559 --> 00:17:07,860 my test case 412 00:17:05,880 --> 00:17:11,699 that is just root endpoint and I'm 413 00:17:07,860 --> 00:17:13,620 passing that function name so um so 414 00:17:11,699 --> 00:17:16,919 whenever it tries to connect the pop sub 415 00:17:13,620 --> 00:17:20,339 method it will uh go to the asynchronous 416 00:17:16,919 --> 00:17:23,220 mock instead right and then uh the rest 417 00:17:20,339 --> 00:17:26,040 is same I have not updated anything in 418 00:17:23,220 --> 00:17:27,839 that code so let's try to run this test 419 00:17:26,040 --> 00:17:32,280 again 420 00:17:27,839 --> 00:17:34,320 so now yes it passed so we have used uh 421 00:17:32,280 --> 00:17:36,960 by test fixtures and we also tried to 422 00:17:34,320 --> 00:17:39,900 Mark some function calls with this test 423 00:17:36,960 --> 00:17:43,200 so that was uh the example of unit test 424 00:17:39,900 --> 00:17:45,840 now let's see an example of end to end 425 00:17:43,200 --> 00:17:48,780 test so before that let's see what this 426 00:17:45,840 --> 00:17:51,000 end-to-end test is for the unit test we 427 00:17:48,780 --> 00:17:52,919 are we were trying to test a single 428 00:17:51,000 --> 00:17:55,320 component or single module at the same 429 00:17:52,919 --> 00:17:57,419 time but for the end-to-end test when 430 00:17:55,320 --> 00:17:59,880 you are testing your software 431 00:17:57,419 --> 00:18:02,280 implication from a specific workflow 432 00:17:59,880 --> 00:18:03,960 from the start to end so that is called 433 00:18:02,280 --> 00:18:06,419 the end-to-end testing 434 00:18:03,960 --> 00:18:09,299 for the end-to-end testing we you need 435 00:18:06,419 --> 00:18:12,419 to have a well-defined workflow before 436 00:18:09,299 --> 00:18:14,340 you can test it so uh so I have 437 00:18:12,419 --> 00:18:15,360 demonstrated a very minimal pipeline 438 00:18:14,340 --> 00:18:18,360 here 439 00:18:15,360 --> 00:18:20,940 so I've already said that because API 440 00:18:18,360 --> 00:18:24,179 has published a subscriber mechanism in 441 00:18:20,940 --> 00:18:27,360 place so I'm I'm going to try and use 442 00:18:24,179 --> 00:18:28,260 that interface to test my whole pipeline 443 00:18:27,360 --> 00:18:32,460 here 444 00:18:28,260 --> 00:18:34,740 so what I'm going to try here is for I I 445 00:18:32,460 --> 00:18:36,660 will be writing a subscriber subscriber 446 00:18:34,740 --> 00:18:38,580 mechanism and that will be subscribed to 447 00:18:36,660 --> 00:18:41,280 a specific Channel called the user 448 00:18:38,580 --> 00:18:43,380 channel so the user channel will receive 449 00:18:41,280 --> 00:18:45,600 all kinds of events when uh user 450 00:18:43,380 --> 00:18:47,580 accounts will be created or updated or 451 00:18:45,600 --> 00:18:50,220 even removed so these kind of messages 452 00:18:47,580 --> 00:18:52,260 will be broadcasted on this channel 453 00:18:50,220 --> 00:18:54,179 so we'll be subscribing to that channel 454 00:18:52,260 --> 00:18:56,940 then we'll be listening on that channel 455 00:18:54,179 --> 00:18:58,559 rather I'd say that we'll be polling out 456 00:18:56,940 --> 00:19:00,780 the channel to receive the continuous 457 00:18:58,559 --> 00:19:03,360 events so that will be the infinite Loop 458 00:19:00,780 --> 00:19:06,240 and meanwhile a user account has will be 459 00:19:03,360 --> 00:19:08,460 created so what I expect is when a user 460 00:19:06,240 --> 00:19:11,400 account gets created the created event 461 00:19:08,460 --> 00:19:13,380 should be broadcasted that channel and 462 00:19:11,400 --> 00:19:16,020 the subscriber should receive it right 463 00:19:13,380 --> 00:19:18,840 so we'll we'll check if that happens or 464 00:19:16,020 --> 00:19:21,780 not and at the end of the workflow I am 465 00:19:18,840 --> 00:19:23,700 going to unsubscribe the channel 466 00:19:21,780 --> 00:19:26,700 okay 467 00:19:23,700 --> 00:19:28,799 so uh how do we write test cases for it 468 00:19:26,700 --> 00:19:30,840 as this is the pipeline that I've shown 469 00:19:28,799 --> 00:19:33,179 it is completely asynchronous all the 470 00:19:30,840 --> 00:19:35,520 functions of that pipeline is going to 471 00:19:33,179 --> 00:19:37,440 be asynchronous and that's why we we 472 00:19:35,520 --> 00:19:38,820 need to use the synchronous test graph 473 00:19:37,440 --> 00:19:41,460 right 474 00:19:38,820 --> 00:19:43,620 so the httpx library provides the 475 00:19:41,460 --> 00:19:46,140 asynchronous or test client and we are 476 00:19:43,620 --> 00:19:48,780 going to use it so I have another I have 477 00:19:46,140 --> 00:19:51,120 defined another Pi text fixtures that is 478 00:19:48,780 --> 00:19:52,919 called test async client and what I'm 479 00:19:51,120 --> 00:19:55,380 doing is I'm creating an instance of 480 00:19:52,919 --> 00:19:58,980 that asynchronous test client 481 00:19:55,380 --> 00:20:00,900 so it is same as we did for the 482 00:19:58,980 --> 00:20:03,720 synchronous test the difference is 483 00:20:00,900 --> 00:20:06,539 instead of using the fake test server 484 00:20:03,720 --> 00:20:09,360 URL as as your base URL you'll be 485 00:20:06,539 --> 00:20:12,000 needing an actual API server URL for 486 00:20:09,360 --> 00:20:15,120 example if my API is running on this URL 487 00:20:12,000 --> 00:20:18,000 called HTTP API Port is 8000 and the 488 00:20:15,120 --> 00:20:19,799 version prefix is latest so if my API is 489 00:20:18,000 --> 00:20:22,140 running on this particular survey URL 490 00:20:19,799 --> 00:20:24,480 then I will need to use that for my 491 00:20:22,140 --> 00:20:26,460 asynchronous test client because at the 492 00:20:24,480 --> 00:20:27,900 end I'm going to run my EPS server and 493 00:20:26,460 --> 00:20:30,539 it will be trying to connect with that 494 00:20:27,900 --> 00:20:32,100 actual web API server 495 00:20:30,539 --> 00:20:35,760 so that is the difference between 496 00:20:32,100 --> 00:20:38,700 synchronous and asynchronous test 497 00:20:35,760 --> 00:20:43,020 the next thing is we will be subscribing 498 00:20:38,700 --> 00:20:45,480 to a channel called user so API has an 499 00:20:43,020 --> 00:20:48,780 endpoint defined to do so 500 00:20:45,480 --> 00:20:51,419 so what I'm doing is I am defining a 501 00:20:48,780 --> 00:20:53,520 test function called test subscribe I'm 502 00:20:51,419 --> 00:20:56,820 using the fixture for the testing 503 00:20:53,520 --> 00:20:58,559 asynchronous client so so I have passed 504 00:20:56,820 --> 00:21:01,140 the fixture name in the argument that is 505 00:20:58,559 --> 00:21:04,200 test async client and please note the 506 00:21:01,140 --> 00:21:06,840 first frame of this snapshot that I have 507 00:21:04,200 --> 00:21:10,200 used two decorators here so first one is 508 00:21:06,840 --> 00:21:12,059 pi test.mark.isync articulator so if you 509 00:21:10,200 --> 00:21:14,220 are writing a test for some kind of 510 00:21:12,059 --> 00:21:16,799 asynchronous function then you need to 511 00:21:14,220 --> 00:21:18,960 Pi test uh then you need to let the 512 00:21:16,799 --> 00:21:21,360 pythons know that this is asynchronous 513 00:21:18,960 --> 00:21:23,520 test and not synchronous test so you can 514 00:21:21,360 --> 00:21:26,940 do that by using this decorator called 515 00:21:23,520 --> 00:21:27,860 pie test dot Market async IO another one 516 00:21:26,940 --> 00:21:30,780 is 517 00:21:27,860 --> 00:21:34,020 bytes.mark.edu order so when you have 518 00:21:30,780 --> 00:21:36,840 multiple tests in your uh testing for a 519 00:21:34,020 --> 00:21:38,520 specific pipeline or a workflow you will 520 00:21:36,840 --> 00:21:40,080 need that some kind of test function 521 00:21:38,520 --> 00:21:42,780 should be executed at the very beginning 522 00:21:40,080 --> 00:21:44,640 of your flow for example if subscription 523 00:21:42,780 --> 00:21:46,740 is not going to happen we we are not 524 00:21:44,640 --> 00:21:49,080 going to unsubscribe anything right so 525 00:21:46,740 --> 00:21:50,940 we we need that this test subscribe 526 00:21:49,080 --> 00:21:53,880 function should be executed at the very 527 00:21:50,940 --> 00:21:55,919 beginning so I have a marked order and 528 00:21:53,880 --> 00:21:58,320 I'm passing the value one so it is the 529 00:21:55,919 --> 00:22:00,240 way of saying that this test should be 530 00:21:58,320 --> 00:22:02,640 executed first 531 00:22:00,240 --> 00:22:05,820 and what I'm doing in the test case the 532 00:22:02,640 --> 00:22:07,860 test subscribe subscribe uh test is I'm 533 00:22:05,820 --> 00:22:10,140 sending the HTTP post request to this 534 00:22:07,860 --> 00:22:12,840 endpoint subscribe slash user endpoint 535 00:22:10,140 --> 00:22:16,080 and what I'm receiving is I'm receiving 536 00:22:12,840 --> 00:22:18,600 a subscription ID as HTTP response so 537 00:22:16,080 --> 00:22:19,980 now see the last uh frame of the 538 00:22:18,600 --> 00:22:22,679 snapshot 539 00:22:19,980 --> 00:22:25,679 a pie test has a way of sharing Global 540 00:22:22,679 --> 00:22:27,600 variables so if I need uh some kind of 541 00:22:25,679 --> 00:22:29,700 information and that should be shared 542 00:22:27,600 --> 00:22:32,340 among all the modules or all the test 543 00:22:29,700 --> 00:22:33,659 cases then I can use the pytus global 544 00:22:32,340 --> 00:22:36,179 variables and this is the way of 545 00:22:33,659 --> 00:22:38,760 defining it so if I write Pi test or 546 00:22:36,179 --> 00:22:42,240 subscription ID so so that subscription 547 00:22:38,760 --> 00:22:44,580 ID variable will be accessible through 548 00:22:42,240 --> 00:22:47,400 all your test cases 549 00:22:44,580 --> 00:22:49,500 so now we are going to listen to that 550 00:22:47,400 --> 00:22:52,559 subscription ID as I've already said 551 00:22:49,500 --> 00:22:55,740 listening is a kind of in a infinite 552 00:22:52,559 --> 00:22:58,020 look so it should be run as a background 553 00:22:55,740 --> 00:22:59,820 task rather than it rather than a 554 00:22:58,020 --> 00:23:03,299 traditional asynchronous test function 555 00:22:59,820 --> 00:23:05,220 right so a way of doing is uh there is a 556 00:23:03,299 --> 00:23:07,440 function there is a package called async 557 00:23:05,220 --> 00:23:10,740 IO and it provides something called task 558 00:23:07,440 --> 00:23:13,140 task objects so you can use that to 559 00:23:10,740 --> 00:23:15,240 create uh to create your task that 560 00:23:13,140 --> 00:23:18,059 should be run in the background 561 00:23:15,240 --> 00:23:20,880 so here I'm going to listen on the 562 00:23:18,059 --> 00:23:24,480 subscription ID and I'm uh and I'm going 563 00:23:20,880 --> 00:23:26,580 to create that task for uh so that would 564 00:23:24,480 --> 00:23:28,559 be that would be run the background task 565 00:23:26,580 --> 00:23:31,140 because this is the way of defining a 566 00:23:28,559 --> 00:23:33,900 background task in asynchronous code so 567 00:23:31,140 --> 00:23:36,780 I have used asyncio.create method and 568 00:23:33,900 --> 00:23:39,360 I'm passing the endpoint HTTP get 569 00:23:36,780 --> 00:23:41,880 endpoint to that Handler so it will 570 00:23:39,360 --> 00:23:43,860 return me the task Handler and from the 571 00:23:41,880 --> 00:23:46,679 time to time I can also track the status 572 00:23:43,860 --> 00:23:50,400 of that Handler 573 00:23:46,679 --> 00:23:53,159 so now this is the main function of this 574 00:23:50,400 --> 00:23:56,159 whole workflow I've defined a test case 575 00:23:53,159 --> 00:23:58,679 uh called test Pipeline and please note 576 00:23:56,159 --> 00:24:01,500 that this uses The Decorator called Pi 577 00:23:58,679 --> 00:24:03,900 testoc mat.dependency so what it means 578 00:24:01,500 --> 00:24:05,880 is this if some kind of test cases 579 00:24:03,900 --> 00:24:08,340 depends on variety of test cases you can 580 00:24:05,880 --> 00:24:11,220 Define the dependency like this so it 581 00:24:08,340 --> 00:24:13,380 shows that this test function uh depends 582 00:24:11,220 --> 00:24:16,860 on test subscribe so if the test 583 00:24:13,380 --> 00:24:19,740 subscribe gets failed or anything happen 584 00:24:16,860 --> 00:24:21,179 to that test case this test case will 585 00:24:19,740 --> 00:24:24,659 simply be skipped 586 00:24:21,179 --> 00:24:25,919 so that is the utility of Depends 587 00:24:24,659 --> 00:24:29,039 decorator 588 00:24:25,919 --> 00:24:31,980 now in the test function I am creating 589 00:24:29,039 --> 00:24:34,440 one listen task so I'm polling uh for 590 00:24:31,980 --> 00:24:36,419 the different kind of listen events uh 591 00:24:34,440 --> 00:24:39,780 listen events by by using this task 592 00:24:36,419 --> 00:24:41,100 Handler and it is returning task listen 593 00:24:39,780 --> 00:24:43,020 task 594 00:24:41,100 --> 00:24:46,080 and meanwhile what I'm doing is I'm 595 00:24:43,020 --> 00:24:48,360 creating a user account so I'm sending 596 00:24:46,080 --> 00:24:50,059 HTTP post request to the user Handler 597 00:24:48,360 --> 00:24:52,679 and I'm passing very basic information 598 00:24:50,059 --> 00:24:55,020 that is username and password to just 599 00:24:52,679 --> 00:24:58,440 create a user account so what I expect 600 00:24:55,020 --> 00:25:00,480 is the task listener should receive an 601 00:24:58,440 --> 00:25:03,480 event that an user account has been 602 00:25:00,480 --> 00:25:06,059 created so if if the status has been 603 00:25:03,480 --> 00:25:08,340 updated for the task Handler I can get 604 00:25:06,059 --> 00:25:09,840 the status using the await keyword so 605 00:25:08,340 --> 00:25:12,419 what I've done is 606 00:25:09,840 --> 00:25:16,740 I've used a weight and then my task 607 00:25:12,419 --> 00:25:19,679 Handler so if sorry so if I get the 608 00:25:16,740 --> 00:25:23,280 event data from my task Handler and I I 609 00:25:19,679 --> 00:25:26,760 also can verify my event data that if I 610 00:25:23,280 --> 00:25:28,260 intend to receive the uh user a user 611 00:25:26,760 --> 00:25:30,299 creation event then I should have 612 00:25:28,260 --> 00:25:32,880 received it right so I've used a bunch 613 00:25:30,299 --> 00:25:35,940 of assate statements to verify that 614 00:25:32,880 --> 00:25:38,640 so I have uh that event data should have 615 00:25:35,940 --> 00:25:41,100 like two parameters one is the operation 616 00:25:38,640 --> 00:25:43,260 and another one is the ID so it shows me 617 00:25:41,100 --> 00:25:45,659 that operation is created means user 618 00:25:43,260 --> 00:25:48,120 account has been created and ID will 619 00:25:45,659 --> 00:25:50,400 show that what is the idea of the user 620 00:25:48,120 --> 00:25:52,980 user account that has just been created 621 00:25:50,400 --> 00:25:55,679 so you can use bunch of acid statement 622 00:25:52,980 --> 00:25:57,840 to verify that cloud event as well 623 00:25:55,679 --> 00:26:00,360 and at the end of the flow I am 624 00:25:57,840 --> 00:26:04,340 unsubscribing to the channel 625 00:26:00,360 --> 00:26:07,260 so um I have uh used another decorator 626 00:26:04,340 --> 00:26:10,320 stock market order and have passed value 627 00:26:07,260 --> 00:26:12,539 last so when you want some function to 628 00:26:10,320 --> 00:26:15,059 be executed at the very end of your flow 629 00:26:12,539 --> 00:26:16,919 then you can do that by providing last 630 00:26:15,059 --> 00:26:19,440 as a value to Your Pie test order 631 00:26:16,919 --> 00:26:21,659 decorator so I've done it so unsubscribe 632 00:26:19,440 --> 00:26:24,299 is something that will be executed at 633 00:26:21,659 --> 00:26:27,059 the very very end of the flow 634 00:26:24,299 --> 00:26:29,279 and now we have the actual test function 635 00:26:27,059 --> 00:26:31,260 called test unsubscribe and what I'm 636 00:26:29,279 --> 00:26:33,000 doing is I'm just sending HTTP post 637 00:26:31,260 --> 00:26:35,279 request to the to the unsubscribe 638 00:26:33,000 --> 00:26:37,919 endpoint and again I'm using that pie 639 00:26:35,279 --> 00:26:40,140 test or subscription ID variable here so 640 00:26:37,919 --> 00:26:42,299 I have shared that variable among all 641 00:26:40,140 --> 00:26:45,480 the test cases and I've used at so many 642 00:26:42,299 --> 00:26:47,159 places so that is uh the reason that I 643 00:26:45,480 --> 00:26:49,919 have declared it as a global variable 644 00:26:47,159 --> 00:26:52,559 and I'm at the end I am just verifying 645 00:26:49,919 --> 00:26:53,760 that if the HTTP response code is 200 or 646 00:26:52,559 --> 00:26:56,520 not 647 00:26:53,760 --> 00:26:58,500 so that was the all the test cases of 648 00:26:56,520 --> 00:27:00,240 endpoint is now it's time to run all the 649 00:26:58,500 --> 00:27:03,120 tests 650 00:27:00,240 --> 00:27:05,940 so for this I need to actually run my 651 00:27:03,120 --> 00:27:08,159 API server and then I would need to run 652 00:27:05,940 --> 00:27:10,440 my Reddit server as well because for the 653 00:27:08,159 --> 00:27:12,659 publisher subscriber mechanism I have 654 00:27:10,440 --> 00:27:15,900 used a Reddit server so I've done that 655 00:27:12,659 --> 00:27:17,700 and after starting my all the servers as 656 00:27:15,900 --> 00:27:19,140 I'm running the test from the terminal 657 00:27:17,700 --> 00:27:21,960 itself 658 00:27:19,140 --> 00:27:24,059 so it shows that all the test cases that 659 00:27:21,960 --> 00:27:26,700 I have run from my end-to-end test so 660 00:27:24,059 --> 00:27:28,620 you can see that test subscribe executed 661 00:27:26,700 --> 00:27:30,960 at the very beginning because I I pass 662 00:27:28,620 --> 00:27:33,360 the order value as 1 for that test case 663 00:27:30,960 --> 00:27:36,240 and another one is the test plan test 664 00:27:33,360 --> 00:27:38,940 Pipeline and at the end it uh it runs 665 00:27:36,240 --> 00:27:42,240 the test unsubscribe method 666 00:27:38,940 --> 00:27:46,320 so uh the pi test function also gives 667 00:27:42,240 --> 00:27:49,020 you the status and uh yeah it also shows 668 00:27:46,320 --> 00:27:51,000 the Temptation that it took to run your 669 00:27:49,020 --> 00:27:53,400 oil test 670 00:27:51,000 --> 00:27:58,140 so because of the time constraint I just 671 00:27:53,400 --> 00:28:00,600 uh could explain two two test cases that 672 00:27:58,140 --> 00:28:02,700 is unit test and end to end test if you 673 00:28:00,600 --> 00:28:04,320 are interested in if you want to check 674 00:28:02,700 --> 00:28:06,900 some of the more examples from the 675 00:28:04,320 --> 00:28:09,960 condenser API that I have put the GitHub 676 00:28:06,900 --> 00:28:12,539 link and you can go and check that 677 00:28:09,960 --> 00:28:14,960 so that result that was all for me thank 678 00:28:12,539 --> 00:28:14,960 you so much 679 00:28:17,980 --> 00:28:21,900 [Applause] 680 00:28:19,679 --> 00:28:23,159 thank you very much here is a small gift 681 00:28:21,900 --> 00:28:24,840 as a thank you for giving a session 682 00:28:23,159 --> 00:28:27,299 thank you and for 10 days that haven't 683 00:28:24,840 --> 00:28:29,940 been able to see this it is a mug with 684 00:28:27,299 --> 00:28:30,960 this year's 2023 artwork on it so it's 685 00:28:29,940 --> 00:28:32,760 the exclusive speaker mode 686 00:28:30,960 --> 00:28:33,600 congratulations thank you thank you so 687 00:28:32,760 --> 00:28:35,640 much 688 00:28:33,600 --> 00:28:38,000 ah 689 00:28:35,640 --> 00:28:38,000 we