tests added
This commit is contained in:
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
32
tests/test_basic.py
Normal file
32
tests/test_basic.py
Normal 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
10
tests/test_fixtures.py
Normal 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()
|
||||
Reference in New Issue
Block a user