Skip to content

Commit

Permalink
refactor: remove redundant access_token fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
azharcodeit committed Jul 17, 2024
1 parent 9c6c04d commit faf42ab
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 25 deletions.
23 changes: 0 additions & 23 deletions src/backend/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import json
import logging
import os
import time
from io import BytesIO
from pathlib import Path
from typing import Any, Generator
Expand All @@ -37,7 +36,6 @@

from app.auth.auth_routes import get_or_create_user
from app.auth.auth_schemas import AuthUser, FMTMUser
from app.auth.osm import create_tokens
from app.central import central_crud
from app.config import encrypt_value, settings
from app.db.database import Base, get_db
Expand Down Expand Up @@ -320,27 +318,6 @@ async def entities(odk_project):
yield entities


@pytest.fixture(scope="function")
async def access_token(admin_user):
"""A test access and refresh tokens."""
user_data = {
"sub": f"fmtm|{admin_user.id}",
"username": admin_user.username,
"picture": admin_user.profile_img,
"role": admin_user.role,
}
user_data.update(
{
"aud": settings.FMTM_DOMAIN,
"iat": int(time.time()),
"exp": int(time.time()) + 86400, # expiry set to 1 day
}
)

access_token, refresh_token = create_tokens(user_data)
return access_token


# @pytest.fixture(scope="function")
# def get_ids(db, project):
# user_id_query = text(f"SELECT id FROM {DbUser.__table__.name} LIMIT 1")
Expand Down
4 changes: 2 additions & 2 deletions src/backend/tests/test_organisation_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import pytest


async def test_get_organisation(client, access_token, organisation):
async def test_get_organisation(client, organisation):
"""Test get list of organisations."""
response = client.get("/organisation/", headers={"access-token": access_token})
response = client.get("/organisation/")
assert response.status_code == 200

data = response.json()[-1]
Expand Down

0 comments on commit faf42ab

Please sign in to comment.