Skip to content

Commit a8ce2ca

Browse files
committed
Add example tests
1 parent a8a7b9d commit a8ce2ca

15 files changed

+26
-1
lines changed

examples/app/models.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
"""Database models."""
22

3+
import os
4+
35
from flask_sqlalchemy import SQLAlchemy
46
from yaml import safe_load
57

68
from openapi_sqlalchemy import init_model_factory
79

810
db = SQLAlchemy()
911

10-
with open("api.yaml") as spec_file:
12+
models_dir = os.path.dirname(__file__)
13+
with open(os.path.join(models_dir, "api.yaml")) as spec_file:
1114
SPEC = safe_load(spec_file)
1215
MODEL_FACTORY = init_model_factory(base=db.Model, spec=SPEC)
1316

tests/examples/__init__.py

Whitespace-only changes.

tests/examples/app/__init__.py

Whitespace-only changes.

tests/examples/app/conftest.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""Fixtures for example app."""
2+
3+
import connexion
4+
import pytest
5+
6+
7+
@pytest.fixture(scope="session")
8+
def app():
9+
"""Flask app for testing."""
10+
# Adding swagger file
11+
flask_app = connexion.FlaskApp(__name__, specification_dir="../../../examples/app/")
12+
flask_app.add_api("api.yaml", validate_responses=True)
13+
# Connecting to database
14+
flask_app.app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///:memory:"
15+
flask_app.app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
16+
17+
return flask_app.app

tests/examples/app/test_app.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""Tests for example app."""
2+
3+
4+
def test_():
5+
assert False

tests/openapi_sqlalchemy/__init__.py

Whitespace-only changes.
File renamed without changes.

0 commit comments

Comments
 (0)