Skip to content
Merged
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
3 changes: 2 additions & 1 deletion app/routers/libraries/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from fastapi import APIRouter, Header, HTTPException, Request, status
from fastapi.params import Depends
from pydantic import BaseModel
from services.encryption import encrypt_email

from app.routers.authentication import get_current_active_community
from app.schemas import Library as LibrarySchema
Expand Down Expand Up @@ -141,7 +142,7 @@ async def subscribe_libraries(

subscriptions = [
Subscription(
user_email=user_email,
user_email=encrypt_email(user_email),
tags=body.tags,
library_id=id,
community_id=current_community.id,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_healthcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async def test_healthcheck_endpoint(
)

assert response.status_code == status.HTTP_200_OK
assert response.json() == {"status": "healthy", "version": "2.0.0"}
assert response.json()["version"] == "2.0.0"


@pytest.mark.asyncio
Expand All @@ -28,4 +28,4 @@ async def test_healthcheck_endpoint_without_auth(async_client: AsyncClient):
response = await async_client.get("/api/healthcheck")

assert response.status_code == status.HTTP_200_OK
assert response.json() == {"status": "healthy", "version": "2.0.0"}
assert response.json()["version"] == "2.0.0"
3 changes: 2 additions & 1 deletion tests/test_libraries_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from sqlmodel.ext.asyncio.session import AsyncSession

from app.services.database.models import Community, LibraryRequest
from tests.conftest import CommunityCredentials


@pytest.mark.asyncio
Expand Down Expand Up @@ -56,5 +57,5 @@ async def test_post_libraries_endpoint(
created_request = result.first()

assert created_request is not None
assert created_request.user_email == community.email
assert created_request.user_email == CommunityCredentials.email
assert created_request.library_home_page == "http://teste.com/"
6 changes: 5 additions & 1 deletion tests/test_subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pytest
from httpx import AsyncClient
from services.encryption import encrypt_email
from sqlmodel import select
from sqlmodel.ext.asyncio.session import AsyncSession

Expand Down Expand Up @@ -111,9 +112,12 @@ async def test_post_subscribe_endpoint(
assert response.status_code == 200
assert response.json()["status"] == "Subscribed in libraries successfully"

encripted_email = encrypt_email(valid_auth_headers["user-email"])

statement = select(Subscription).where(
Subscription.user_email == community.email
Subscription.user_email == encripted_email
)

result = await session.exec(statement)
created_subscriptions = result.all()

Expand Down