1
00:00:00,274 --> 00:00:01,913
- [Instructor] Hi and
welcome back to the course.

2
00:00:01,913 --> 00:00:03,715
In this video, we're going to test that

3
00:00:03,715 --> 00:00:07,448
our app works up until now,
and that's mainly because

4
00:00:07,448 --> 00:00:09,334
the last video was getting pretty long so

5
00:00:09,334 --> 00:00:12,787
I didn't want to make it too rough on you.

6
00:00:12,787 --> 00:00:16,859
What we've got here is the
folder of this section,

7
00:00:16,859 --> 00:00:21,026
and in it we have the code
and the virtual environment.

8
00:00:22,440 --> 00:00:24,455
Now there's a data.db
there which I'm going

9
00:00:24,455 --> 00:00:28,622
to remove just to make
sure that things are clear.

10
00:00:30,170 --> 00:00:34,337
Now, what we can do is we can run Python,

11
00:00:37,018 --> 00:00:41,185
the command Python code/create_tables.py,

12
00:00:42,056 --> 00:00:44,766
and what that does is
that creates the tables

13
00:00:44,766 --> 00:00:48,349
and the data.db file
in the current folder,

14
00:00:49,416 --> 00:00:51,916
so not inside the code folder.

15
00:00:53,817 --> 00:00:57,984
Now that is fine as long as
we then do Python code/app.py.

16
00:01:01,303 --> 00:01:03,783
If we go into the code folder and then

17
00:01:03,783 --> 00:01:08,450
run app.py then things are
going to start getting messy

18
00:01:08,450 --> 00:01:12,617
because the app is going to
think that data.db is within

19
00:01:14,647 --> 00:01:17,369
the directory in which it ran,

20
00:01:17,369 --> 00:01:20,781
and data.db is not inside
the code directory.

21
00:01:20,781 --> 00:01:24,035
It's in the directory above
it, so as you will see,

22
00:01:24,035 --> 00:01:26,285
if we go into Postman at
this point and try to,

23
00:01:26,285 --> 00:01:29,823
for example, register
we'll error saying that

24
00:01:29,823 --> 00:01:32,924
the table users doesn't exist because

25
00:01:32,924 --> 00:01:35,168
of exactly what I just said.

26
00:01:35,168 --> 00:01:38,533
As you can see we get an error
here on the terminal as well.

27
00:01:38,533 --> 00:01:42,889
So what we have to do is
to make sure that wherever

28
00:01:42,889 --> 00:01:45,480
we create data.db, we make sure that

29
00:01:45,480 --> 00:01:49,300
we run our app from that folder as well.

30
00:01:49,300 --> 00:01:52,716
Okay, so I'm going to go back
into the section folder which

31
00:01:52,716 --> 00:01:56,549
has the code data.db and
venv, and now we have

32
00:01:57,441 --> 00:02:01,608
to choose to either remove
data.db, go into the code folder,

33
00:02:04,196 --> 00:02:08,843
and run the create_tables here
which then creates data.db in

34
00:02:08,843 --> 00:02:12,426
this folder, and then
we can do run app.py,

35
00:02:14,513 --> 00:02:17,230
and as you will see, this will work.

36
00:02:17,230 --> 00:02:21,669
We can now register, or
another option is for us

37
00:02:21,669 --> 00:02:25,566
to remove data.db there,
go to the parent folder,

38
00:02:25,566 --> 00:02:29,612
run Python code/create_tables.py,

39
00:02:29,612 --> 00:02:34,216
and then run Python
code/app.py, and then when we go

40
00:02:34,216 --> 00:02:38,810
to Postman you'll see
that we can also register.

41
00:02:38,810 --> 00:02:41,519
It doesn't give us the error
where the table's not found.

42
00:02:41,519 --> 00:02:43,490
Okay, so you have to
choose one of the two.

43
00:02:43,490 --> 00:02:46,247
Either run both commands
on the parent folder,

44
00:02:46,247 --> 00:02:48,551
or run both commands on the code folder,

45
00:02:48,551 --> 00:02:52,376
but not one on each folder
because then it won't be able

46
00:02:52,376 --> 00:02:56,640
to find where the sequalite file is, okay?

47
00:02:56,640 --> 00:02:58,203
Just wanted to make that clear.

48
00:02:58,203 --> 00:03:00,296
And now, we can see that we can

49
00:03:00,296 --> 00:03:03,007
indeed register which is good.

50
00:03:03,007 --> 00:03:06,374
Let's see if we can
authenticate, and indeed we can,

51
00:03:06,374 --> 00:03:08,681
and remember we've not really
changed how the code works.

52
00:03:08,681 --> 00:03:10,815
We're still sending in the body with

53
00:03:10,815 --> 00:03:13,161
the chase username and password.

54
00:03:13,161 --> 00:03:15,831
We're still registering in the same way.

55
00:03:15,831 --> 00:03:19,472
Now lets get the items
which should be empty,

56
00:03:19,472 --> 00:03:21,366
and indeed it is.

57
00:03:21,366 --> 00:03:25,725
Let's post another item,
I'm going to put in a phone,

58
00:03:25,725 --> 00:03:30,291
very cheap phone $15.99,
and that seems to be there.

59
00:03:30,291 --> 00:03:32,263
Let's retrieve the items again,

60
00:03:32,263 --> 00:03:35,450
and the item seems to contain the phone.

61
00:03:35,450 --> 00:03:38,704
Now let's get the specific phone,

62
00:03:38,704 --> 00:03:39,854
and as you can see it tells me that

63
00:03:39,854 --> 00:03:43,351
the signature has expired
because the gate in

64
00:03:43,351 --> 00:03:47,670
the item requires a JWT,
so I'm going to make sure

65
00:03:47,670 --> 00:03:51,837
to in there and put it in, and
there we get the phone back.

66
00:03:53,882 --> 00:03:56,882
Now we're going to delete the phone,

67
00:04:00,625 --> 00:04:02,969
and this seems to work as
well, and finally we're going

68
00:04:02,969 --> 00:04:06,544
to put a new phone in,
and that seems to work,

69
00:04:06,544 --> 00:04:09,831
and then we're going to change the price,

70
00:04:09,831 --> 00:04:11,470
and that also seems to
work, and once again,

71
00:04:11,470 --> 00:04:15,637
if we get the items we see
then the phone is there.

72
00:04:22,699 --> 00:04:25,324
Then we can delete it again.

73
00:04:25,324 --> 00:04:29,491
Okay so everything so far
seems to work, and make sure

74
00:04:30,337 --> 00:04:33,425
that it does for you as well,

75
00:04:33,425 --> 00:04:36,797
because as we move code
around and as we refactor

76
00:04:36,797 --> 00:04:40,455
the code and improve it,
things are bound to break,

77
00:04:40,455 --> 00:04:42,577
and we want to make sure
that we catch things

78
00:04:42,577 --> 00:04:46,680
that break quickly so that
we can fix them before

79
00:04:46,680 --> 00:04:48,448
we've written so much new code that

80
00:04:48,448 --> 00:04:51,978
we don't know where to start fixing, okay?

81
00:04:51,978 --> 00:04:55,465
And also, now that we're here
we might as well duplicate

82
00:04:55,465 --> 00:04:59,632
the section five, edit it,
and call it section six,

83
00:05:00,477 --> 00:05:01,505
because once again we're going

84
00:05:01,505 --> 00:05:04,922
to be including a few new things as well.

85
00:05:05,907 --> 00:05:08,149
Okay, in the next video
we're going to look at

86
00:05:08,149 --> 00:05:11,063
a bit more into Postman just to make life

87
00:05:11,063 --> 00:05:15,093
a bit easier for you, and then
we'll move on into coding on

88
00:05:15,093 --> 00:05:17,216
the following video after that.

89
00:05:17,216 --> 00:05:18,989
So I'll see you in the next one.

