-
Notifications
You must be signed in to change notification settings - Fork 21
/
test_app.py
48 lines (39 loc) · 1.69 KB
/
test_app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Basic Tests for the application
import pytest
import json
from flask import url_for
class TestApp:
def test_ping(self, client):
"""Test server responds"""
res = client.get(url_for("ping"))
assert res.status_code == 200
assert res.json == {"ping": "pong"}
def test_hawkeye_contentful(self, contentful_client):
"""Test Hawkeye is a charcter in the content"""
post = contentful_client.entry("2SiSYthyVaasy84IssCQAw")
assert post.title == "Hawkeye"
assert post.slug == "hawkeye"
assert post.first_appearance == "Tales of Suspense #57 (Sept. 1964)"
assert post.gif is not None
def test_content_type_post(self, contentful_client):
"""Test content model of a post"""
post_content_type = contentful_client.content_type("post")
assert len(post_content_type.fields) == 4
title = next(d for d in post_content_type.fields if d.id == "title")
assert title.id == "title"
assert title.type == "Symbol"
slug = next(d for d in post_content_type.fields if d.id == "slug")
assert slug.id == "slug"
assert slug.type == "Symbol"
first_appearance = next(
d for d in post_content_type.fields if d.id == "first_appearance"
)
assert first_appearance.id == "first_appearance"
assert slug.type == "Symbol"
gif = next(d for d in post_content_type.fields if d.id == "gif")
assert gif.id == "gif"
assert gif.type == "Link"
def test_hawkeye_get(self, client):
"""Test Hawkeye is listed as a charcter on the index route"""
res = client.get(url_for("index"))
assert b"Hawkeye" in res.data