Skip to content

Commit

Permalink
Remove httpx pin, fix tests, & test plugins individually (#574)
Browse files Browse the repository at this point in the history
* Remove httpx pin

* add relaxed pin back in

* undo pins to check ci

* Fix tests

* use github flake8

* add constraint back in

* fix plugin tests

* fix tos tests

* improve plugin testing

* hmmm

* why doesn't this run

* test status code some more

* better?

* huh

* pipefail

* die

* try reordering

* is mamba the issue?

* do it with set instead

* use set +e

* fix bash variables

* use string instead

* string comparison

* remove double shell definition

* Log which plugins failed

* last polish

* Fix test that i broke for testing

* trigger CI
  • Loading branch information
simonbohnen committed Dec 14, 2022
1 parent ae38be7 commit 7f77638
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 17 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,26 @@ jobs:
for f in ./plugins/quetz_*
do
echo "::group::Testing plugin${f}"
echo "::group::Testing plugin ${f}"
quetz plugin install $f
# We want to test all the plugins, regardless of whether one fails
set +e
pytest -v $f
pytest_exit_code=$?
set -e
echo "::endgroup::"
if [ $pytest_exit_code -ne 0 ]; then
echo "::error::Tests for plugin $f failed!"
tests_failed="true"
fi
done
if [ "$tests_failed" == "true" ]; then
echo "::error::Some plugin tests failed!"
exit 1
fi
- uses: codecov/codecov-action@v1
with:
verbose: true
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repos:
rev: 22.3.0
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
- repo: https://github.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies:
- typer
- authlib=0.15.5
- psycopg2
- httpx=0.20.0
- httpx>=0.22.0
- sqlalchemy
- sqlalchemy-utils
- sqlite
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def test_valid_login(client, db, testuser, testpassword):
response = client.post(
"/auth/sql/authorize",
data={"username": testuser, "password": testpassword},
allow_redirects=False,
)
# Assert that we get a redirect to the main page
assert response.status_code == 303
Expand Down Expand Up @@ -204,6 +205,7 @@ def test_changing_password(owner_client, client, db, testuser, testpassword):
response = client.post(
"/auth/sql/authorize",
data={"username": testuser, "password": testpassword},
allow_redirects=False,
)
# Assert that we get a redirect to the main page
assert response.status_code == 303
Expand Down Expand Up @@ -237,6 +239,7 @@ def test_changing_password(owner_client, client, db, testuser, testpassword):
response = client.post(
"/auth/sql/authorize",
data={"username": testuser, "password": newpassword},
allow_redirects=False,
)
# Assert that we get a redirect to the main page
assert response.status_code == 303
6 changes: 2 additions & 4 deletions plugins/quetz_tos/tests/test_quetz_tos.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import io

import pytest
from fastapi import HTTPException

Expand All @@ -13,8 +11,8 @@ def upload_tos(client):
url = "/api/tos/upload?lang=EN&lang=FR"

files_to_upload = (
('tos_files', ("tos_en.txt", io.StringIO("demo tos en"))),
('tos_files', ("tos_fr.txt", io.StringIO("demo tos fr"))),
('tos_files', ("tos_en.txt", b"demo tos en")),
('tos_files', ("tos_fr.txt", b"demo tos fr")),
)

response = client.post(url, files=files_to_upload)
Expand Down
4 changes: 3 additions & 1 deletion quetz/tests/api/test_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,9 @@ def test_url_with_slash(auth_client, public_channel, db, remote_session):
mirror_url = "http://mirror_url"

response = auth_client.post(
f"/api/channels/{public_channel.name}/mirrors/", json={"url": mirror_url}
f"/api/channels/{public_channel.name}/mirrors/",
json={"url": mirror_url},
allow_redirects=False,
)

assert response.status_code == 307
Expand Down
2 changes: 1 addition & 1 deletion quetz/tests/api/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def test_delete_channel_member_no_member(auth_client, public_channel, other_user


def test_upload_wrong_file_type(auth_client, public_channel):
files = {"files": ("my_package-0.1-0.tar.bz", "dfdf")}
files = {"files": ("my_package-0.1-0.tar.bz", b"dfdf")}
response = auth_client.post(
f"/api/channels/{public_channel.name}/files/", files=files
)
Expand Down
4 changes: 2 additions & 2 deletions quetz/tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,13 +393,13 @@ def test_private_channels(data, client):
def test_private_channels_create_package(data, client):
# public access to public channel
response = client.post(
f'/api/channels/{data.channel1.name}/packages', '{"name": "newpackage1"}'
f'/api/channels/{data.channel1.name}/packages', json={"name": "newpackage1"}
)
assert response.status_code == 401

# public access to private channel
response = client.post(
f'/api/channels/{data.channel2.name}/packages', '{"name": "newpackage1"}'
f'/api/channels/{data.channel2.name}/packages', json={"name": "newpackage1"}
)
assert response.status_code == 401

Expand Down
16 changes: 11 additions & 5 deletions quetz/tests/test_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,13 +792,19 @@ def test_add_and_register_mirror(auth_client, dummy_session_mock):
)
assert response.status_code == 201

base_url = auth_client.base_url
base_url_path = auth_client.base_url.path

dummy_session_mock.post.assert_called_with(
"http://mirror3_host/api/channels/my-channel/mirrors",
json={
"url": auth_client.base_url + '/get/mirror-channel',
"api_endpoint": auth_client.base_url + '/api/channels/mirror-channel',
"metrics_endpoint": auth_client.base_url
+ '/metrics/channels/mirror-channel',
"url": base_url.copy_with(path=base_url_path + 'get/mirror-channel'),
"api_endpoint": base_url.copy_with(
path=base_url_path + 'api/channels/mirror-channel'
),
"metrics_endpoint": base_url.copy_with(
path=base_url_path + 'metrics/channels/mirror-channel'
),
},
headers={},
)
Expand Down Expand Up @@ -919,7 +925,7 @@ def test_disabled_methods_for_mirror_channels(
assert response.status_code == 405
assert "not implemented" in response.json()["detail"]

files = {"files": ("my_package-0.1.tar.bz", "dfdf")}
files = {"files": ("my_package-0.1.tar.bz", b"dfdf")}
response = client.post(f"/api/channels/{mirror_channel.name}/files/", files=files)
assert response.status_code == 405
assert "not implemented" in response.json()["detail"]
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ install_requires =
fastapi
fsspec
h2
httpx~=0.20.0
httpx>=0.22.0
importlib-metadata
itsdangerous
jinja2
Expand Down

0 comments on commit 7f77638

Please sign in to comment.