Python for the .NET developer Transcripts
Chapter: Testing
Lecture: Python app under test

Login or purchase this course to watch this video and the rest of the course contents.
0:00 You saw the C# version
0:01 now let's see the Python version
0:03 of just the app and the library.
0:05 Of course, we're going to write the test
0:07 and put all of that stuff in place
0:09 but here we have the guitar app
0:10 and here we have the lib that we talked about before
0:13 so we have our guitar class
0:15 and down here we have the function
0:17 that given a style, which is a string
0:19 and it will return a list of guitars.
0:22 First off, we're going to lowercase the style
0:24 we'll log out a little bit of information here.
0:27 The log oh yeah the log is down at the bottom, down here
0:31 and of course it's just going to say print out
0:33 just like we saw before. Some color output
0:35 and we also have, if we go back up here
0:37 we have the get the guitars from the DB
0:40 and down here we have a function
0:42 which simulates getting data from the database
0:45 and of course prints out
0:46 this should be shown in the app
0:48 but again, not when we're actually trying to do testing
0:51 cause that would mean we're depending on a dependency
0:53 which we want to mock out or something to that effect.
0:56 Alright, well lets go ahead and run the app here
0:58 see what we got. Should look pretty familiar
1:01 I want to see an electric guitar
1:04 alright, here are your eight options
1:05 and notice, here's your log and here's your note
1:09 that hey we're going to the database.
1:10 You can see acoustic. See one
1:14 write one, but of course
1:15 we're using our dependencies and in the app
1:17 that's exactly what we want.
1:18 In the test, it's exactly what we want to avoid.
1:21 So this is the code that we're starting from
1:23 for this chapter
1:24 and our goal is to write some tests
1:26 that basically, the same test that we had before
1:29 tests that we can filter for a particular type of guitars
1:32 tests that we can get all the guitars
1:35 and tests that there's an error
1:36 if we try to access a guitar
1:39 that's not right. Let's actually take this out
1:41 so we can maybe discover a bug
1:43 that way it just introduced
1:44 and test that with out Python code
1:46 and our pytest test.