API Testing with Python 3 & PyTest, Backend Automation 2020

API Testing with Python 3 & PyTest, Backend Automation 2020

English | MP4 | AVC 1280×720 | AAC 44KHz 2ch | 17.5 Hours | 7.33 GB


Learn to build framework for API automation testing (backend testing) using Python and PyTest, SQL, Reports, Docker …

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 Serivces 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 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.

Critical addition to your resume

If you are getting into the QA world or you are looking to advance your career, having API testing skill 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 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 interview 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 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 a 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 you’ll learn

  • How to write API automation (backend automation) using Python 3
  • How to validate API response
  • How to build automation framework
  • BONUS: SQL Crash Course
  • How to validate database
  • How to generate reports for your tests (pytest-html, Allure, jUnit)
  • How to create a real eCommerce WordPress site locally
  • How to run tests in Docker container
  • How to use PyTest (most popular unit testing framework)


+ Table of Contents

Introduction To The Course
1 Welcome To The Course
2 Table Of Content
3 Preview of End Result
4 About The Test Site and Ecommerce API

Installation and Setup of Tools
5 Intro to Installation and Setup Section
6 Installing Python On Mac
7 Installing Python On Windows
8 How to Use Virtual Environment
9 Create Virtual Environment For The Course
10 Install IDE (PyCharm)
11 PyCharm Project & Virtual Environment
12 About Our Options for WordPress
13 Install Local For WordPress
14 Create A Site
15 Using localhost instead of Site Name
16 Install AMPS & WordPress
17 Install Plugin WooCommerce
18 Adding Sample Products to the Site
19 Setup and Verify API with Postman and Python
20 Install MySQL WorkBench & Connect to Database

Crash Course on PyTest
21 Introduction to PyTest
22 Selecting Tests By Markers (Tags)
23 Setup & Teardown (fixtures)
24 PyTest HTML Report

Build Framework and Automate Test Cases
25 How To Use The Provided Code
26 Project Structure Overview
27 TCID-29 – Discussion – create a customer endpoint
28 TCID-29 – Design Test Code Template
29 Helper – Email & Password Generator (TCID-29)
30 Helper – Crete Customer (TCID-29)
31 Helper – ‘POST’ request (TCID-29)
32 Authenticate our API call
33 Helper – Credentials
34 TCID-29 Verify ‘Create Customer’ API Response
35 Setting Environment Variables
36 Customers DAO
37 Helper – Database Connect & SQL
38 TCID-29 Verify Database
39 TCID-30 – Discussion – List All Customers Endpoint
40 TCID-30 – List All Customers (GET Call)
41 TCID-47 – Create Customer Existing Email (negative test)
42 Run All Customers Test Cases
43 Assignment – Automate TCID-24 (Get All Products)
44 TCID-24 Get All Products – Implementation
45 TCID-25 Get Product By ID
46 TCID-26 Create Simple Product
47 TCID-51-1 List Product With Filter after
48 TCID-51-2 List Product With Filter after – db verification
49 TCID-51-3 List Product With Filter after – more pages
50 WooCommerce Python Library Intro
51 TCID-48-1 Place Guest Order – Discussion
52 TCID-48-2 Place Guest Order – Read Payload From File
53 TCID-48-3 Place Guest Order – Make The Call
54 TCID-48-4 Place Guest Order -Validate Response
55 TCID-48-5 Place Guest Order -Validate db
56 TCID-49 Place Order With New Customer
57 Setup Example with TCID-49
58 Use Configs for Database Connections
59 TCID-55-1 Update Order Status – Cancelled
60 TCID-55-2 Update Order Status – Cancelled
61 TCID-55,56,57 Parametrization
62 TCID-58 Update Order Status – Invalid Status
63 TCID-59 Update Order – customer note

EXERCISES
64 Exercise TCID-61 Verify update ‘regular price’ updates the ‘price’ field
65 Exercise TCID-63 Verify update ‘sale price 0’ will set field ‘on sale’=True
66 Exercise TCID-64 Verify update ‘sale price= ‘ will set field ‘on sale’=False
67 Exercise TCID-65 Verify update ‘sale price’ updates the ‘sale price’ field
68 Exercise TCID-60 Order with 50% off coupon should reduce total by 50%
69 Exercise TCID-37 Create a new coupon with ‘discount type=percent’
70 Exercise TCID-38 Create a new coupon with ‘discount type=fixed cart’
71 Exercise TCID-39 Create a new coupon with ‘discount type=fixed product’
72 Exercise TCID-40 Create a new coupon with ‘discount type=invalid string’

Running Tests In Docker Container
73 Docker Section Introduction
74 Create Dockerfile & Build Image
75 Start Container and Try Test Run – unsuccessful
76 Connect to Database From Container
77 Use Docker Volumes To Avoid Image Rebuild
78 Make API Cal from Container
79 Run Tests From Outside Container
80 Wrapper Script To Run Tests In Container
81 Color Output From Docker Run
82 Using Debugger (pdb) With Docker
83 Timestamp The Report
84 Docker Section Summary

BONUS SECTION SQL (MySQL) Crash Course
85 Introduction to the SQL Crash Course
86 Introduction to SQL
87 Setup Database and Data
88 SQL SELECT Query (Reading Data)
89 SQL SELECT Query Continued
90 SQL SELECT Query Continued 2
91 SQL IN Clause
92 SQL SELECT Sub-Query
93 SQL LIKE Clause
94 Intro to SQL JOIN
95 SQL JOIN
96 SQL LEFT JOIN
97 SQL Special Functions
98 SQL INSERT INTO
99 SQL CREATE TABLE
100 SQL DROP and TRUNCATE
101 SQL Crash Course Conclusion

Introduction to the course
102 IMPORTANT NOTICE
103 Introduction

Prepare Our Tools
104 Summary of Tools we will use and why
105 Install Web server and database on our local machine (AMPPS)
106 Installing WordPress on local machine
107 Installing WooCommerce (our e-commerce) Plugin (key and secreate)
108 Installing WooCommerce Python Client
109 Installing MySQL WorkBench

WooCommerce Settings and Documentation
110 Configuring WooCommerce API
111 WooCommerce Official Documentation Reveiw

Test Structure and Organization
112 Project Structure
113 Create our structure

Custom tools (scripts we will use for DB and API)
114 REST API Module Create ‘class’ and test the API
115 Review Please!
116 REST API Module ‘POST’ and ‘GET’ methods
117 DB Connection Module connect and ‘SELECT’ statement
118 DB Connection Module ‘UPDATE’ statement

TEST CASES
119 PRODUCTS endpoint introduction to the ‘products’ endpoint
120 PRODUCTS endpoint Positive TC-1 create payload & make api call
121 PRODUCTS endpoint Positive TC-1 verify the response
122 PRODUCTS endpoint Quick manual check the db for the created product
123 PRODUCTS endpoint Positive TC-1 verify info in the DB
124 PRODUCTS endpoint Negative TC-1 empty payload
125 PRODUCTS endpoint Negative TC-2 missing ‘title’ parameter
126 PRODUCTS endpoint Negative TC-3 empty string for ‘title’ parameter
127 PRODUCTS endpoint Negative TC verifications function for negative test
128 PRODUCTS endpoint Negative TC-3 continue empty string for ‘title’ parameter

TEST RUNNER TOOL “PY.TEST”
129 Introduction to py.test
130 Run products tests with py.test

CUSTOMERS endpoint test (API to create new customer)
131 CUSTOMERS endpoint Intro to ‘customers’ endpoint
132 CUSTOMERS endpoint create random user information
133 CUSTOMERS endpoint positive test, create payload and make API call
134 CUSTOMERS endpoint positive test, verify API response
135 CUSTOMERS endpoint SQL to verify customer in db
136 CUSTOMERS endpoint function to get customer info from db
137 CUSTOMERS endpoint create helper module, move random generator function
138 CUSTOMERS endpoint Positive TC verify customer created in db (with assert)
139 CUSTOMERS endpoint Positive TC verify customer created in db (with if-else)