Skip to content

Commit

Permalink
fix: fix failed org back-end tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
hamed-valiollahi committed Nov 15, 2024
1 parent 82b8977 commit 32123ba
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions backend/lcfs/tests/test_organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ async def test_get_organization_by_id_bceid_user(

@pytest.mark.anyio
async def test_create_organization_success(
client: AsyncClient, fastapi_app: FastAPI, mock_user_role
client: AsyncClient, fastapi_app: FastAPI, set_mock_user
) -> None:
# Set mock user role for organization creation
mock_user_role([RoleEnum.GOVERNMENT])
set_mock_user(fastapi_app, [RoleEnum.GOVERNMENT])
payload = {
"name": "Test Organizationa",
"operatingName": "Test Operating name",
Expand Down Expand Up @@ -108,13 +108,12 @@ async def test_create_organization_success(
assert response.status_code == status.HTTP_201_CREATED



@pytest.mark.anyio
async def test_update_organization_success(
client: AsyncClient, fastapi_app: FastAPI, mock_user_role
client: AsyncClient, fastapi_app: FastAPI, set_mock_user
) -> None:
# Set mock user role for organization update.
mock_user_role([RoleEnum.GOVERNMENT])
set_mock_user(fastapi_app, [RoleEnum.GOVERNMENT])
payload = {
"name": "Test Organization",
"operatingName": "Test Operating name",
Expand Down Expand Up @@ -150,10 +149,10 @@ async def test_update_organization_success(

@pytest.mark.anyio
async def test_update_organization_failure(
client: AsyncClient, fastapi_app: FastAPI, mock_user_role
client: AsyncClient, fastapi_app: FastAPI, set_mock_user
) -> None:
# Set mock user role for organization update
mock_user_role([RoleEnum.GOVERNMENT])
set_mock_user(fastapi_app, [RoleEnum.GOVERNMENT])
payload = {
"name": "Test Organizationa",
"operatingName": "Test Operating name",
Expand Down Expand Up @@ -333,22 +332,21 @@ async def create_organization(
client: AsyncClient,
fastapi_app: FastAPI,
payload: dict,
#role: RoleEnum = RoleEnum.GOVERNMENT
# role: RoleEnum = RoleEnum.GOVERNMENT
) -> object:
"""Helper function to create an organization and return the response."""
#mock_user_role([role])
# set_mock_user([role])
url = fastapi_app.url_path_for("create_organization")
response = await client.post(url, json=payload)
return response


async def update_organization(
client: AsyncClient,
fastapi_app: FastAPI,
organization_id: int,
payload: dict
client: AsyncClient, fastapi_app: FastAPI, organization_id: int, payload: dict
) -> object:
"""Helper function to update an organization and return the response."""
url = fastapi_app.url_path_for("update_organization", organization_id=organization_id)
url = fastapi_app.url_path_for(
"update_organization", organization_id=organization_id
)
response = await client.put(url, json=payload)
return response

0 comments on commit 32123ba

Please sign in to comment.