
Learn to test RESTful APIs with Python and PyTest, build a scalable backend automation framework, and extend it to frontend testing with Selenium, using a real e-commerce API and Docker.
Discover API testing with Python 3 and PyTest by building a local WordPress site with WooCommerce, using environment variables and automating tests.
Preview of end result: build a full test framework for backend, database, and API testing, with easy front-end extension using pytest, PyCharm, Docker, and a scalable package structure.
Set up a local WordPress and WooCommerce environment to practice backend API testing, using the WooCommerce RESTful API to create and validate orders, customers, and coupons with automated tests.
Install and configure tools for the course, set up Python environments, and build a local WordPress with WooCommerce to practice API testing using Python and Postman.
Learn to install and manage multiple python versions on a mac, verify python and python3 locations with which, and use the official site for installation (brew not supported).
Install Python 3 and Python 2 on Windows, verify installations with where python and python --version, and configure environment variables to manage both versions via path.
Learn to use Python virtual environments to isolate projects and manage multiple library versions, with creation, activation, and running scripts via the full interpreter path.
Create and activate two virtual environments for the course—one python 3 and one python 2—inside the project, then install core packages like requests, pytest, and mysql.
Explore python ide options, with PyCharm as the most popular choice, and use Ctrl-click navigation to jump to function definitions.
Set up a PyCharm project and configure a Python virtual environment for API testing with Python 3, including selecting the interpreter, paths, and switching between environments.
Explore options to run WordPress for a private website test, including docker, local wp, amps, and manual installs, with WordPress needing files, a mysql database, and a web server.
Learn to run WordPress locally with MAMP, configure the Apache document route and ports, install WordPress, and set up a MySQL database with Workbench.
Learn how to install Local by Flywheel, create a WordPress site locally, configure admin credentials, and access WordPress via localhost or an IP address, with provisioning steps.
Install and activate the WooCommerce plugin to turn a WordPress site into an e-commerce platform, configure the setup wizard, and prepare basic testing with coupons.
Install and import WooCommerce sample products using the WordPress importer or XML data, then view a populated shop with priced items, including sale items, ready for checkout.
Explore setting up the WooCommerce REST API, generating API keys, and testing with Postman and Python to validate endpoints for orders, products, and users on a local server.
Learn to connect a local WordPress site's database using MySQL Workbench, configure a local MySQL connection, and explore core WordPress tables like posts, post meta, and user data.
Learn how to select pytest tests using markers (tags), apply markers to tests or classes, and run with -m to combine, exclude, or negate tags.
Learn to use pytest fixtures for setup and teardown, including fixtures with module scope to run once per module, return data to tests, and use yield for teardown.
Learn to generate test reports with pytest-html in Python, producing an HTML report (and optionally JUnit XML or Allure) for local runs and Jenkins workflows.
Set up the provided code in a virtual environment, install with setup.py, and run tests with pytest, using environment variables for credentials and configuring the WordPress WooCommerce test site.
Set up the automation framework by building a Python package structure with setup.py using find_packages, and prepare to run tests with pytest and generate reports.
Automate test case 29 for the create a customer endpoint in the WooCommerce API using Python and PyTest; validate the 201 response, email, and customer creation in the database.
Design a test code template for api testing with pytest, automating a create customer test with a basic payload, and outlining modular helpers for api calls, data, and database verification.
Create a reusable random email and password generator in utilities.generic_utilities to support test user creation, integrate it into test payloads, and facilitate API calls in Python and PyTest.
Build modular helper classes to automate customer creation in API testing for TCID-29, generate random emails and passwords, and design a reusable API call helper for backend tests.
Develop a post request helper in utilities using the requests library to call the customer creation endpoint with a json payload and headers, as shown in test case 29.
Develop API authentication using Python requests and OAuth1, integrate credential handling with environment variables to avoid hard coding, and validate response status codes (200/201) in a reusable test framework.
Create a credentials utility that reads WooCommerce API keys from environment variables, avoiding hard-coded secrets, with validation and a static method for easy retrieval.
Guides end-to-end api testing for create customer with python 3 and pytest, validating status codes and the json response, including email and username checks.
Create a bash env file to store api keys as environment variables and load them with source. Windows users can use a corresponding .bat file.
Continue creating test case 29 by validating the created user's presence in the database through a customers dao and a future db helper.
Create a database utility to run SQL and verify a created user exists in the database after an API call.
Finalize test case 29 by validating API responses and database records within the Python PyTest framework, tying random emails to DB IDs and assertions.
Automate a smoke test for the WooCommerce get all customers API using Python 3 and PyTest, asserting the response is non-empty.
Learn to implement a pytest based get all customers test (tcid-30) for a REST API, verifying a non-empty response with status 200 and a configurable base URL.
Post a create customer API call using an existing email from the database, and assert a 400 status and an email exists error message.
execute all customer tests together by tagging them with a customers marker, run pytest -m customers, and generate an HTML report to verify outcomes.
Automate test case id 24 for the get all products API. Write the code to test the products endpoint, mirroring the get all customers approach.
Automate TCID-24 get all products test in api testing with python 3 and pytest, verify the response is not empty, and illustrate per-page pagination on the products endpoint.
Automate TCID-25 to retrieve a product by id using a db-backed test data setup and a products api helper, then verify the 200 response matches the database.
Automate creating a product via api with pytest by generating a random name, posting a payload with name, type, and price to the products endpoint, and validating a 201 response.
Automates api testing for listing products with the after filter. Shows building a date-filter payload, invoking the endpoint, and validating results against the database with pytest smoke and regression marks.
Develop a PyTest-based API test that lists products after a date, verifies results against a database query via product dao, and notes pagination limits.
Test products with an after-date filter using paginated API calls, collect all results across pages, and validate against the database. A regression test using pytest ensures reliability.
Learn how the official WooCommerce Python library authenticates and calls WooCommerce APIs, and build a reusable API helper to compare library usage with a custom request approach.
Automate test case 48 to place a guest order via the orders create API, using a reusable json payload updated for each test, and simulate checkout without a customer.
Automate a paid guest order test with pytest by loading a payload from data/create_order_payload.json, retrieving a random product from the database, and posting the order via a helper.
Automate guest order creation by updating a templated payload with additional args, post to the WooCommerce API, and validate a 201 response and guest checkout data.
Automate guest order creation, validate a non-empty response, assert the customer id equals zero, confirm a single line item, and ensure the status code is 201 before database verification.
Automate test case 48 for placing a guest order using API testing with Python and PyTest, validating the response and verifying order lines in the WooCommerce database.
Automates test case 49 for creating an order with a new or existing customer using Python, PyTest, and helper objects, refactoring validation into a reusable verify order function.
Explore using pytest fixtures for setup and teardown to share a random product and helper objects across tests, demonstrating module-scoped setup for api testing with guest and new user orders.
Course Description
Learn how to use Python to test the back-end of web services or APIs. We use industry-standard real eCommerce RESTful API to practice testing using Python programming language.
We will build a framework using one of the most popular testing tools PyTest. The framework we will build will be extendable and scalable to be able to include frontend (Selenium WebDriver) testing.
The skills learned here are used in any Web Services testing.
BONUS: SQL Crash Course
You will learn how to use SQL to read and write to/from databases. We will use MySQL for our main test site so we will use the same database to learn SQL. SQL (sequel) is a critical skill for any test engineer (manual or automation needs to know basic SQL).
The crash course in SQL is short and precise. Topics only directly related to automation are covered. Great addition to your resume and interview process.
A critical addition to your resume
If you are getting into the QA world or you are looking to advance your career, having API testing skills will accelerate your success. Python is one of the most popular languages to use in software testing, and knowing how to use it for API/Backend testing will expand your pool of possibilities.
In addition to using Python for API/Backend testing, the tools we will use are a great addition to your resume. We will be using industry-standard tools that can be applied to several tasks beyond API testing.
After completion of this course, you will be able to go through interviews as if you have API testing experience. You will also have plenty of APIs to test and practice.
Content and Overview
In this course, we will spend some time creating an eCommerce application on our local machine. We will install a package that includes a web server and database. Using this package we will install WordPress and install necessary plugins to make it an eCommerce application. The eCommerce application gives us all the APIs we will test.
We have access to the database so we will test API data against the database. We will create an efficiently structured test framework and learn how to use Python to perform our verification.
We will also learn how to use a Python test runner tool "pytest" see why test runner tools are critical for automation testing.
What am I going to get from this course?
35 + lectures (continuously adding more examples)
Plenty of APIs (endpoints) for you to practice with beyond this class
Enough material and examples to be able to create a project and maintain a GitHub repo
Industry-standard tools to add to your resume.
Like
MySQL Workbench
MAMP (package with Apache, MySQL)
WordPress
WooCommerce