- Create the database access module. This module will have the ElasticClient class definition. It will also have any additional definitions that this class needs.
- This recipe will use unittest and doctest to create a unified suite of tests. It will use the Mock class from unittest.mock, as well as json. Since this module is separate from the unit under test, it needs to import ch11_r08_load, which has the class definitions that will be tested:
from unittest.mock import *
- Here's the overall framework for a test case. We'll fill in the setUp() and runTest() methods of this test below. The name shows that we're given an instance of ElasticClient, when we invoke ...
Get Modern Python Cookbook now with O’Reilly online learning.
O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.