Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 7065d97a

Přidáno uživatelem Stanislav Král před asi 4 roky(ů)

#8219 - Added pytest dependency used for testing

- added a simple testcase that checks whether index page is being served correctly

Zobrazit rozdíly:

requirements.txt
1
Flask==1.1.2
2
pytest==6.2.2
tests/conftest.py
1
import pytest
2

  
3
from app import app as flask_app
4

  
5

  
6
# initialize our Flask app for testcases
7
@pytest.fixture
8
def app():
9
    yield flask_app
10

  
11

  
12
@pytest.fixture
13
def client(app):
14
    return app.test_client()
tests/sample_test.py
1
def test_addition():
2
    assert 1 + 1 == 2
3

  
4

  
5
def test_index(client):
6
    # fetch index page
7
    res = client.get('/')
8

  
9
    # check HTTP status code
10
    assert res.status_code == 200
11

  
12
    # check response content
13
    assert res.get_data(as_text=True) == "Welcome to the X.509 management application homepage!"

Také k dispozici: Unified diff