WEBVTT 00:03.680 --> 00:09.740 It is now time to write the tests for a profile status view said class and we can actually start by 00:09.980 --> 00:15.410 copying part of the code we used for their profile view said test case class. 00:16.040 --> 00:18.230 So you are below. 00:18.420 --> 00:23.190 Like so this is going to be profile to view said test case. 00:23.300 --> 00:26.890 List you avail is going to be start to say the least. 00:27.290 --> 00:31.940 And you also need to make a couple of adjustments here because we need to create a new start to see 00:32.010 --> 00:41.260 instances so self-doubt starts and of course we're going to need to import both profile starters and 00:42.700 --> 00:52.880 profile starters serialize the like so now we can use FISA to actually create this fantasy instance 00:52.930 --> 01:02.360 so self that start to see what's provided that those not objects that create the user profile equals 01:02.470 --> 01:02.890 self. 01:02.890 --> 01:14.160 Dot user dot profile and of course status content equals status test. 01:14.290 --> 01:18.610 Same as we did here with the profile view said test case class. 01:18.650 --> 01:23.230 We can now check the list end point. 01:23.630 --> 01:33.170 So but this time of course this is going to be Test status least authenticated and test the status least 01:33.290 --> 01:35.040 and authenticated. 01:35.060 --> 01:38.720 Let's now run the tests right away and let's see what happens. 01:38.900 --> 01:41.490 Python manage that by test. 01:43.930 --> 01:45.920 The system is run eight tests. 01:46.010 --> 01:47.400 If you worked as expected. 01:47.410 --> 01:48.190 Awesome. 01:48.250 --> 01:54.720 So we're going back to our classic can now write in other method and let us know try to create a new 01:54.730 --> 01:55.530 start to see instance. 01:55.560 --> 02:07.990 So DFA test starters create self we can define a data dictionary we have status as a matter of fact 02:08.460 --> 02:09.160 we use the. 02:09.200 --> 02:15.490 So starts content a new start. 02:16.750 --> 02:17.650 And yet we can check. 02:17.650 --> 02:27.970 Response equals self client dot post this time clearly self-taught list you add L which in fact in this 02:27.970 --> 02:30.180 case we can just call you at L. 02:30.310 --> 02:36.280 So like so. 02:36.350 --> 02:46.790 So first of all let's check this that was code self-taught assert equal response not status code and 02:46.790 --> 02:51.710 of course we expect start was not HDP to a one created. 02:51.890 --> 03:03.890 We can then check the user profile or self-taught assert equal response that data user profile and we 03:03.890 --> 03:09.860 want you to be there means you of course because that e.g. is the user name of the user that we're using 03:09.860 --> 03:11.710 to authenticate a request. 03:11.780 --> 03:14.480 And finally let's check the status quo into itself. 03:14.490 --> 03:29.100 So self let's assert equal response dot data status content which has to be in your status. 03:29.210 --> 03:41.090 Let's also try to retrieve a single status so DFA test single status retrieve self and one way that 03:41.090 --> 03:44.000 we can do so involves using the serialized class. 03:44.000 --> 03:56.360 So serialize their data equals course it's going to be profile status denies it with instance equals 03:56.450 --> 04:04.580 self dot status that we want the data then yeah we can do a response equals self that's client and dot 04:04.980 --> 04:10.930 get to reverse status detail. 04:11.100 --> 04:16.790 Again remember we get the name for free according to the way we set out router class up. 04:16.790 --> 04:26.390 So keyword arguments equals parameter key one which is of course the status that we've created yet. 04:26.600 --> 04:27.890 Then we can check. 04:27.890 --> 04:32.960 Of course status code is always very important. 04:34.160 --> 04:43.840 And then response data equals GSA dot loads response not content. 04:43.950 --> 04:47.670 Now we can now assert equal. 04:47.750 --> 04:51.760 Well actually self-taught a sort of equal that data 04:56.500 --> 04:57.640 response data. 04:57.640 --> 04:59.200 Let's run out of tests. 05:04.980 --> 05:09.990 So you see we get an error we get an F which stands for fail. 05:09.990 --> 05:12.930 We then read the test that is fail. 05:13.020 --> 05:17.340 And right away we also get the class that are math or these parts of it. 05:17.610 --> 05:20.940 Then we get trace back and a very useful error message. 05:20.940 --> 05:23.280 First of all line 92. 05:23.310 --> 05:27.010 So we know that the error is in line 92. 05:27.180 --> 05:32.820 And then we get a certain error for Android is different then tool 1 and that is because of course we 05:32.820 --> 05:39.300 cannot get an h UDP to a one created without actually creating a new instance which means that we need 05:39.300 --> 05:44.010 to pass data to our End Point let's run the tests. 05:44.310 --> 05:57.260 Once again we now see that it is a small typo yet let's run them one more time and now everything works 05:57.320 --> 05:58.010 just fine. 05:58.400 --> 06:04.820 So as you can see tests are really really useful even just a ladder out of place of maybe forgetting 06:04.820 --> 06:09.830 to pass a parameter to a function will most of the time prevent your application from providing the 06:09.830 --> 06:12.320 functionality that it's supposed to provide. 06:12.320 --> 06:17.720 And of course using automated testing most of the time will allow you to identify a problem and fix 06:17.720 --> 06:18.210 it. 06:18.230 --> 06:21.170 Let's not right the two last methods for our class. 06:21.860 --> 06:26.250 So we can test the update capabilities for our start to see instances. 06:26.270 --> 06:37.910 So therefore Test status update on our self and then we can define a data dictionary something like 06:38.480 --> 06:50.040 content updated India response equals self the client that puts the reverse. 06:50.180 --> 07:00.690 For starters the tail we've keyword arguments being a dictionary primary key one. 07:00.710 --> 07:11.480 And with data equals data we can now check this status code and the response data so stethoscope we 07:11.480 --> 07:14.230 expect H2 to be 200. 07:14.240 --> 07:23.230 OK and the start was content as to be of course content updated. 07:23.300 --> 07:24.920 And now for the final method 07:28.000 --> 07:32.980 we can check and update your random user. 07:33.460 --> 07:37.990 So first of all I'm going to copy the code we've used here. 07:38.300 --> 07:38.580 So 07:42.060 --> 07:44.150 this way. 07:44.370 --> 07:55.920 So content we can set you up have been hacked then we can delete this because if everything works as 07:55.920 --> 08:09.110 it should we can get HP for all 3 for beta then maybe Ecuador's indent this one like so here and here. 08:09.340 --> 08:09.580 Well 08:13.330 --> 08:17.030 let's not run our tests one last time. 08:17.030 --> 08:17.330 So 08:20.910 --> 08:25.000 in this you see of course everything works as expected. 08:25.120 --> 08:25.370 Okay. 08:25.400 --> 08:28.530 So that was it for January's framework level three. 08:28.550 --> 08:30.620 The next section is all about the future. 08:30.620 --> 08:31.200 Yes. 08:31.240 --> 08:33.990 We will make a great introduction learning how to use it. 08:34.070 --> 08:36.950 Get it ready to build a full fledged single page application. 08:36.950 --> 08:40.160 We've got this framework in view in the final project of course.