Skip to content

Commit

Permalink
fix tests and update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzay-G committed Jun 18, 2023
1 parent 9892d2e commit 9adb66c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
3 changes: 0 additions & 3 deletions archivy/routes.py
Expand Up @@ -3,7 +3,6 @@
from pkg_resources import require
from shutil import which
from datetime import datetime
import time

import frontmatter
from flask import (
Expand Down Expand Up @@ -55,7 +54,6 @@ def check_perms():
@app.route("/")
@app.route("/index")
def index():
a = time.time()
path = request.args.get("path", "").lstrip("/")
try:
files = data.get_items(path=path)
Expand All @@ -74,7 +72,6 @@ def index():
except FileNotFoundError:
flash("Directory does not exist.", "error")
return redirect("/")
print(time.time() - a)
return render_template(
"home.html",
title=path or "root",
Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Expand Up @@ -6,9 +6,9 @@
# archivy/extensions.py: 6
# archivy/models.py: 13
# archivy/routes.py: 7
Flask == 2.1.3
werkzeug == 2.0.3
jinja2 == 3.0.0
Flask == 2.3.2
werkzeug == 2.3.3
jinja2 == 3.1.2

# archivy/forms.py: 2
Flask_WTF == 1.1.1
Expand Down Expand Up @@ -53,7 +53,7 @@ validators == 0.15.0
# archivy/__init__.py: 9
# archivy/models.py: 13
# archivy/routes.py: 10
flask-login == 0.5.0
flask-login == 0.6.2

click_plugins
html2text
Expand Down
20 changes: 9 additions & 11 deletions tests/functional/test_routes.py
@@ -1,13 +1,11 @@
import os
import re

from flask.testing import FlaskClient
from flask import request
from flask_login import current_user
from responses import RequestsMock, GET
from werkzeug.security import generate_password_hash

from archivy.helpers import get_max_id, get_db
from archivy.helpers import get_max_id
from archivy.data import get_dirs, create_dir, get_items, get_item


Expand Down Expand Up @@ -157,7 +155,7 @@ def test_logging_in(test_app, client: FlaskClient):
follow_redirects=True,
)
assert resp.status_code == 200
assert request.path == "/"
assert resp.request.path == "/"
assert current_user


Expand All @@ -168,7 +166,7 @@ def test_logging_in_with_invalid_creds(test_app, client: FlaskClient):
follow_redirects=True,
)
assert resp.status_code == 200
assert request.path == "/login"
assert resp.request.path == "/login"
assert b"Invalid credentials" in resp.data


Expand All @@ -183,7 +181,7 @@ def test_edit_user(test_app, client: FlaskClient):
follow_redirects=True,
)

assert request.path == "/"
assert resp.request.path == "/"

client.delete("/logout")

Expand All @@ -193,7 +191,7 @@ def test_edit_user(test_app, client: FlaskClient):
follow_redirects=True,
)
assert resp.status_code == 200
assert request.path == "/"
assert resp.request.path == "/"
# check information has updated.


Expand All @@ -203,7 +201,7 @@ def test_logging_out(test_app, client: FlaskClient):
client.delete("/logout")

resp = client.get("/", follow_redirects=True)
assert request.path == "/login"
assert resp.request.path == "/login"


def test_create_dir(test_app, client: FlaskClient):
Expand All @@ -216,7 +214,7 @@ def test_create_dir(test_app, client: FlaskClient):
)

assert resp.status_code == 200
assert request.args.get("path") == "testing"
assert resp.request.args.get("path") == "testing"
assert "testing" in get_dirs()
assert b"Folder successfully created" in resp.data

Expand All @@ -227,7 +225,7 @@ def test_creating_without_dirname_fails(test_app, client: FlaskClient):
)

assert resp.status_code == 200
assert request.path == "/"
assert resp.request.path == "/"
assert b"Could not create folder." in resp.data


Expand Down Expand Up @@ -409,4 +407,4 @@ def test_bookmarklet_upload(test_app, client):
)
assert resp.status_code == 200
assert title in str(resp.data)
assert "/dataobj/" in request.path
assert "/dataobj/" in resp.request.path

0 comments on commit 9adb66c

Please sign in to comment.