Creating the test files

Open the test.py file and let's start by adding a few imports:

from dateutil.relativedelta import relativedeltafrom django.test import TestCasefrom django.utils import timezonefrom .models import OrderCustomer, Orderfrom .status import Statusfrom .exceptions import OrderAlreadyCompletedErrorfrom .exceptions import OrderCancellationErrorfrom .exceptions import InvalidArgumentError

Great! We start by importing the relative delta function so we can easily perform date operations, like adding days or months to a date. This will be very helpful when testing the methods that get orders for a certain period of time.

Now, we import some Django-related things. First is the TestCase class, which is a subclass of unittest.TestCase ...

Get Python Programming Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.