-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat : Added get all Invitations endpoint
- Loading branch information
Showing
3 changed files
with
60 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from unittest.mock import patch, MagicMock | ||
import pytest | ||
from fastapi.testclient import TestClient | ||
from datetime import datetime, timedelta, timezone | ||
from uuid_extensions import uuid7 | ||
from api.v1.models.invitation import Invitation | ||
from api.v1.services.user import user_service, UserService | ||
from main import app | ||
from api.db.database import get_db | ||
from api.v1.models.user import User | ||
|
||
client = TestClient(app) | ||
@pytest.fixture | ||
def mock_db_session(): | ||
with patch("api.db.database.get_db", autospec=True) as mock_get_db: | ||
mock_db = MagicMock() | ||
app.dependency_overrides[get_db] = lambda: mock_db | ||
yield mock_db | ||
app.dependency_overrides = {} | ||
|
||
def test_get_all_invitations(mock_db_session): | ||
|
||
invitations = [Invitation(user_id=str(uuid7()), is_valid = True , organisation_id = str(uuid7()), id=str(uuid7()))] | ||
|
||
mock_db_session.query().all.return_value = invitations | ||
|
||
app.dependency_overrides[user_service.get_current_super_admin] = lambda : User( | ||
id=str(uuid7()), | ||
email="[email protected]", | ||
password="hashed_password", | ||
first_name='Test', | ||
last_name='User', | ||
is_active=True, | ||
created_at=datetime.now(timezone.utc), | ||
updated_at=datetime.now(timezone.utc), | ||
is_superadmin = True | ||
) | ||
|
||
res = client.get('/api/v1/organisations/invites') | ||
|
||
assert res.status_code == 200 | ||
|