Skip to content

Commit

Permalink
add test for issue #129
Browse files Browse the repository at this point in the history
  • Loading branch information
hgrf committed Mar 11, 2023
1 parent 1f593b5 commit 25a6f6c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ class ProductionConfig(Config):


class TestingConfig(Config):
DEBUG = True
SQLALCHEMY_DATABASE_URI = os.environ.get("DATABASE_URL") or "sqlite:///" + os.path.join(
basedir, "database/testing.sqlite"
)
LOG_EXCEPTIONS = True
TESTING = True
WTF_CSRF_ENABLED = False


config = {
Expand Down
26 changes: 26 additions & 0 deletions app/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,32 @@ def test_instantiate_app():
assert app is not None


def test_issue129():
"""Test that the issue #129 is fixed."""
app = create_app("testing")
migrate = Migrate()

# make sure that testing DB does not exist
db_path = app.config.get("SQLALCHEMY_DATABASE_URI").replace("sqlite:///", "")
if os.path.exists(db_path):
os.remove(db_path)

with app.app_context():
db.init_app(app)
migrate.init_app(app, db)
upgrade()

# recreate app to initialize activity table
app = create_app("testing")

with app.test_client() as c:
# log in via HTTP
r = c.post("/auth/login", data={"username": "admin", "password": "admin"})
assert r.status_code == 302
r = c.get("/plugins/../README.md")
assert r.status_code == 404


def test_db_migrations():
"""Test that the database migrations can be run."""
app = create_app("testing")
Expand Down

0 comments on commit 25a6f6c

Please sign in to comment.