Lesson 40 - Page Probe Tests
LEARN
End of Course
- All work must be completed by Friday, Dec 3
- If you have not gotten credit for your projects email me with details
Office Hours
- If you need help please attend office hours
- MWF 1:30-2:30 by Zoom
- Zoom: https://unco.zoom.us/j/99180652183
- Email: mark.seaman@unco.edu
Today
- Page Probe Test Design Patterns
Catalog of Design Patterns
- Design Patterns
- Use this catalog of patterns as you work on projects
- Django Tests
Shrinking World Testing
- Django Tests - Unit tests with test database
- Page Probe Tests - Fetch and examine web pages from local and remote servers
- Hammer Script Tests - Live local and remote servers
Django Tests
- Unit tests with test database
- Tests isolated components
- Does not change production data
Page Probe Tests
- Fetch and examine web pages from local and remote servers
- Use "requests" module in Python to fetch pages
- Use an app to manage test cases
python
def execute_probe(probe):
try:
response = get(probe.page)
except:
response = None
if not response:
status = f'Status Code: Domain not found, {probe.page}'
passed = False
elif response.status_code != 200:
status = f'Status Code: {response.status_code}'
passed = False
elif probe.text not in response.text:
status = f'Text not found: {probe.text}'
passed = False
else:
status = f'Matched: {probe.text}'
passed = True
Result.create(probe=probe, output=status, passed=passed)
Hammer Script Tests
- Live local and remote servers
- Used to test and
- Complete server with command scripts
- Local file environment
BUILD
Practice
- Clone my repo and study the code in Page Probe Source Code
- Build the code and experiment with it
- Set up tests for your favorite web sites
- Do it simple; do it now!