Skip to content

Instantly share code, notes, and snippets.

@twyle
Last active May 13, 2022 07:27
Show Gist options
  • Save twyle/9bf4b1967247da3d484d51d2bf39520c to your computer and use it in GitHub Desktop.
Save twyle/9bf4b1967247da3d484d51d2bf39520c to your computer and use it in GitHub Desktop.
Testing the home route.
# -*- coding: utf-8 -*-
"""This module tests the home route."""
def test_home(client):
"""Tests that the home route returns ok message on GET request.
GIVEN we have the /api/v1 route
WHEN we send a GET request
THEN we should get a 200 OK response
"""
resp = client.get('/api/v1')
assert resp.status_code == 200
def test_home_bad_http_method(client):
"""Tests that the home route returns method not allowed message on POST request.
GIVEN we have the /api/v1 route
WHEN we send a POST request
THEN we should get a 405 error code in the response
"""
resp = client.post('/api/v1')
assert resp.status_code == 405
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment