Modern Python Solutions - Part 3

Section 1: Testing

This section will give us a detailed description of the different testing frameworks used in Python.

The Course Overview

Using docstring for Testing

Testing Functions that Raise Exceptions

Handling Common doctest Issues

Creating Separate Test Modules and Packages

Combining the unittest and doctest Tests

Testing Things that Involve Dates and Time

Testing Things That Involve Randomness

Mocking External Resources

Browse Videos

Section 2: Web Services

This section will show you, number of ways for creating RESTful web services and also serving static or dynamic content.

Implementing Web Services with WSGI

Using the Flask Framework for RESTful APIs

Parsing the Query String in a Request

Making REST Requests Using urllib

Parsing the URL Path

Parsing a JSON Request

Implementing Authentications for Web Services

Browse Videos

Section 3: Application Integration

This section will show you the ways that we can design applications that can be composed to create larger, more sophisticated composite applications. We will also look at the complications that can arise from composite applications and the need to centralize some features, such as command-line parsing.

Finding Configuration Files

Using YAML for Configuration Files

Using Python for Configuration Files

Using Logging for Control and Audit Output

Combining Two Applications into One

Combining Many Applications Using the Command Design Pattern

Controlling Complex Sequences of Steps

Browse Videos

1.1 The Course Overview

1.2 Using docstring for Testing

Good Python includes docstrings inside every module, class, function, and method. Many tools can create useful, informative documentation from the docstrings. How can we turn examples into proper test cases? Let's explore this question.

1.4 Handling Common doctest Issues

Doctest examples require an exact match with the text. How can we write doctest examples that handle hash randomization or floating-point implementation details appropriately? This video will enable you to answer this question.

1.7 Testing Things that Involve Dates and Time

Many applications rely on datetime.datetime.now() to create a timestamp. When we use this with a unit test, the results are essentially impossible to predict. How can we work with datetime stamps? Let's look into this.

1.8 Testing Things That Involve Randomness

Many times we create random values or put values into random order. In many statistical tests, repeated random shuffling or random subset calculations are done. Let's see how we can unit test algorithms that involve randomness.

Define an outline of the overall test class and a mock version of the random.choice() function

2.3 Parsing the Query String in a Request

This video will show you a better way to handle a query string and have a more sophisticated structure that behaves like a dictionary with single values for the common case, and a more complex object for the rare cases where a field key is duplicated and has multiple values.

Define a route and the view function

Extract the values of a unique key with the get() method

Use the getlist() method and define the main program that runs the server

2.5 Parsing the URL Path

The path to a resource can be quite complex. It's common in RESTful web services to use the path information to identify groups of resources, individual resources, and even relationships among resources. How can we handle complex path parsing? Let's answer this question.

2.7 Implementing Authentications for Web Services

This video will show a self-service application in which there is no defined set of users. This means that there must be a web service to create new users that doesn't require any authentication. All other services will require a properly authenticated user.

3.2 Using YAML for Configuration Files

Python offers a variety of ways to package application inputs and configuration files. Let's look at writing files in YAML notation because it's elegant and simple. This video will show you how you can represent configuration details in YAML notation.

3.4 Using Logging for Control and Audit Output

Python offers the logging package, which can be used to direct the ancillary output to a separate file. It can also be used to format and filter that additional output. How can we use logging properly? Let's see this.

Import logging module and implement basic logging features into the existing functions

3.5 Combining two Applications into One

This video will walk you through a design pattern that would allow several Python language components to be combined into a larger application. You will learn to combine applications to create a composite.

Import the essential functions from the working modules

Create a new function that combines the existing functions from the other applications