tests added

This commit is contained in:
2021-11-20 07:53:41 +00:00
parent 472fa5263a
commit 52b505211a
13 changed files with 50 additions and 6 deletions

0
tests/__init__.py Normal file
View File

32
tests/test_basic.py Normal file
View File

@@ -0,0 +1,32 @@
from .test_fixtures import client,app
import json
import logging
import pytest
@pytest.fixture
def index_html(client):
resp = client.get('/index/')
data= resp.get_data(as_text=True)
return data
def test_index(app,client):
# Try to get "index"
resp = client.get('index.json')
data = json.loads(resp.get_data(as_text=True))
assert resp.status_code == 200
assert data['page']['title'] == "IndexPage"
def test_index_html(app,client):
# Try to get "index"
resp = client.get('/index/')
#data= resp.get_data(as_text=True)
#app.logger.debug()
assert resp.status_code == 200
def test_links_in_index(index_html):
assert 'href="/topic1/"' in index_html
def test_text_in_index(index_html):
assert 'asdfasdfasdf' in index_html

10
tests/test_fixtures.py Normal file
View File

@@ -0,0 +1,10 @@
import os
import pytest
from flaskpages import create_app
@pytest.fixture
def app():
return create_app()
@pytest.fixture
def client(app):
return app.test_client()