Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker/api/requirements: fix api container build failure #305

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ async def translate_null_query_params(query_params: dict):
return translated


@app.get('/node/{node_id}', response_model=Union[Regression, Node],
@app.get('/node/{node_id}', response_model=Union[Regression, Node, None],
response_model_by_alias=False)
async def get_node(node_id: str, kind: str = "node"):
"""Get node information from the provided node id"""
Expand Down
2 changes: 1 addition & 1 deletion docker/api/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
aioredis[hiredis]==2.0.0
cloudevents==1.9.0
fastapi[all]==0.68.1
fastapi[all]==0.99.1
fastapi-pagination==0.9.3
passlib==1.7.4
pydantic==1.10.5
Expand Down
9 changes: 0 additions & 9 deletions tests/e2e_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
from httpx import AsyncClient
from motor.motor_asyncio import AsyncIOMotorClient

from fastapi.testclient import TestClient

from api.main import app

BASE_URL = 'http://api:8000/latest/'
Expand All @@ -22,13 +20,6 @@
db = db_client[DB_NAME]


@pytest.fixture(scope='session')
def test_client():
"""Fixture to get FastAPI Test client instance"""
with TestClient(app=app, base_url=BASE_URL) as client:
yield client


@pytest.fixture(scope='session')
async def test_async_client():
"""Fixture to get Test client for asynchronous tests"""
Expand Down
10 changes: 6 additions & 4 deletions tests/e2e_tests/test_count_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,35 @@
import pytest


@pytest.mark.asyncio
@pytest.mark.dependency(
depends=[
'e2e_tests/test_pipeline.py::test_node_pipeline'],
scope='session')
def test_count_nodes(test_client):
async def test_count_nodes(test_async_client):
"""
Test Case : Test KernelCI API GET /count endpoint
Expected Result :
HTTP Response Code 200 OK
Total number of nodes available
"""
response = test_client.get("count")
response = await test_async_client.get("count")
assert response.status_code == 200
assert response.json() >= 0


@pytest.mark.asyncio
@pytest.mark.dependency(
depends=[
'e2e_tests/test_pipeline.py::test_node_pipeline'],
scope='session')
def test_count_nodes_matching_attributes(test_client):
async def test_count_nodes_matching_attributes(test_async_client):
"""
Test Case : Test KernelCI API GET /count endpoint with attributes
Expected Result :
HTTP Response Code 200 OK
Number of nodes matching attributes
"""
response = test_client.get("count?name=checkout")
response = await test_async_client.get("count?name=checkout")
assert response.status_code == 200
assert response.json() >= 0
7 changes: 5 additions & 2 deletions tests/e2e_tests/test_root_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@

"""End-to-end test functions for KernelCI API root handler"""

import pytest

def test_root_endpoint(test_client):

@pytest.mark.asyncio
async def test_root_endpoint(test_async_client):
"""Test root handler"""
response = test_client.get("/latest")
response = await test_async_client.get("/")
assert response.status_code == 200
assert response.json() == {"message": "KernelCI API"}
10 changes: 6 additions & 4 deletions tests/e2e_tests/test_subscribe_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@
import pytest


@pytest.mark.asyncio
@pytest.mark.dependency(
depends=['e2e_tests/test_user_creation.py::test_create_regular_user'],
scope='session')
@pytest.mark.order(4)
def test_subscribe_node_channel(test_client):
async def test_subscribe_node_channel(test_async_client):
"""
Test Case : Test KernelCI API '/subscribe' endpoint with 'node' channel
Expected Result :
HTTP Response Code 200 OK
JSON with subscription 'id' and 'channel' keys
"""
response = test_client.post(
response = await test_async_client.post(
"subscribe/node",
headers={
"Authorization": f"Bearer {pytest.BEARER_TOKEN}"
Expand All @@ -32,18 +33,19 @@ def test_subscribe_node_channel(test_client):
assert response.json().get('channel') == 'node'


@pytest.mark.asyncio
@pytest.mark.dependency(
depends=['e2e_tests/test_user_creation.py::test_create_regular_user'],
scope='session')
@pytest.mark.order(4)
def test_subscribe_test_channel(test_client):
async def test_subscribe_test_channel(test_async_client):
"""
Test Case : Test KernelCI API '/subscribe' endpoint with 'test_channel'
Expected Result :
HTTP Response Code 200 OK
JSON with subscription 'id' and 'channel' keys
"""
response = test_client.post(
response = await test_async_client.post(
"subscribe/test_channel",
headers={
"Authorization": f"Bearer {pytest.BEARER_TOKEN}"
Expand Down
10 changes: 6 additions & 4 deletions tests/e2e_tests/test_unsubscribe_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@
import pytest


@pytest.mark.asyncio
@pytest.mark.dependency(
depends=[
'e2e_tests/test_subscribe_handler.py::test_subscribe_node_channel'],
scope='session')
@pytest.mark.order("last")
def test_unsubscribe_node_channel(test_client):
async def test_unsubscribe_node_channel(test_async_client):
"""
Test Case : Test KernelCI API '/unsubscribe' endpoint with 'node' channel
Expected Result :
HTTP Response Code 200 OK
"""
response = test_client.post(
response = await test_async_client.post(
f"unsubscribe/{pytest.node_channel_subscription_id}",
headers={
"Authorization": f"Bearer {pytest.BEARER_TOKEN}"
Expand All @@ -29,18 +30,19 @@ def test_unsubscribe_node_channel(test_client):
assert response.status_code == 200


@pytest.mark.asyncio
@pytest.mark.dependency(
depends=[
'e2e_tests/test_subscribe_handler.py::test_subscribe_test_channel'],
scope='session')
@pytest.mark.order("last")
def test_unsubscribe_test_channel(test_client):
async def test_unsubscribe_test_channel(test_async_client):
"""
Test Case : Test KernelCI API '/unsubscribe' endpoint with 'test_channel'
Expected Result :
HTTP Response Code 200 OK
"""
response = test_client.post(
response = await test_async_client.post(
f"unsubscribe/{pytest.test_channel_subscription_id}",
headers={
"Authorization": f"Bearer {pytest.BEARER_TOKEN}"
Expand Down
10 changes: 6 additions & 4 deletions tests/e2e_tests/test_user_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,17 @@ async def test_create_regular_user(test_async_client):
pytest.BEARER_TOKEN = response.json()['access_token']


@pytest.mark.asyncio
@pytest.mark.dependency(depends=["test_create_regular_user"])
def test_whoami(test_client):
async def test_whoami(test_async_client):
"""
Test Case : Test KernelCI API /whoami endpoint
Expected Result :
HTTP Response Code 200 OK
JSON with 'id', 'username', 'hashed_password'
and 'active' keys
"""
response = test_client.get(
response = await test_async_client.get(
"whoami",
headers={
"Accept": "application/json",
Expand All @@ -129,16 +130,17 @@ def test_whoami(test_client):
assert response.json()['profile']['username'] == 'test_user'


@pytest.mark.asyncio
@pytest.mark.dependency(depends=["test_create_regular_user"])
def test_create_user_negative(test_client):
async def test_create_user_negative(test_async_client):
"""
Test Case : Test KernelCI API /user endpoint when requested
with regular user's bearer token.
Expected Result :
HTTP Response Code 401 Unauthorized
JSON with 'detail' key denoting 'Access denied' error
"""
response = test_client.post(
response = await test_async_client.post(
"user/test",
headers={
"Accept": "application/json",
Expand Down