-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release-0.2.0' into hotfix-organizationName-FinalSupply…
…Equipment
- Loading branch information
Showing
18 changed files
with
443 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,12 @@ jobs: | |
LCFS_REDIS_PORT: 6379 | ||
LCFS_REDIS_PASSWORD: development_only | ||
APP_ENVIRONMENT: dev | ||
LCFS_CHES_CLIENT_ID: mock_client_id | ||
LCFS_CHES_CLIENT_SECRET: mock_client_secret | ||
LCFS_CHES_AUTH_URL: http://mock_auth_url | ||
LCFS_CHES_SENDER_EMAIL: [email protected] | ||
LCFS_CHES_SENDER_NAME: Mock Notification System | ||
LCFS_CHES_EMAIL_URL: http://mock_email_url | ||
|
||
- name: Upload pytest results | ||
if: always() | ||
|
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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import json | ||
from lcfs.web.api.email.repo import CHESEmailRepository | ||
import pytest | ||
|
||
from unittest.mock import patch | ||
from unittest.mock import patch, AsyncMock | ||
from httpx import AsyncClient | ||
from fastapi import FastAPI | ||
|
||
|
@@ -16,6 +17,20 @@ | |
) | ||
from lcfs.services.s3.client import DocumentService | ||
|
||
@pytest.fixture | ||
def mock_email_repo(): | ||
return AsyncMock(spec=CHESEmailRepository) | ||
|
||
@pytest.fixture | ||
def mock_environment_vars(): | ||
with patch("lcfs.web.api.email.services.settings") as mock_settings: | ||
mock_settings.ches_auth_url = "http://mock_auth_url" | ||
mock_settings.ches_email_url = "http://mock_email_url" | ||
mock_settings.ches_client_id = "mock_client_id" | ||
mock_settings.ches_client_secret = "mock_client_secret" | ||
mock_settings.ches_sender_email = "[email protected]" | ||
mock_settings.ches_sender_name = "Mock Notification System" | ||
yield mock_settings | ||
|
||
# get_compliance_periods | ||
@pytest.mark.anyio | ||
|
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
from fastapi import HTTPException | ||
from lcfs.db.models.user.Role import RoleEnum | ||
from lcfs.web.api.compliance_report.update_service import ComplianceReportUpdateService | ||
from lcfs.web.api.notification.services import NotificationService | ||
import pytest | ||
from unittest.mock import AsyncMock, MagicMock, patch | ||
from lcfs.db.models.compliance.ComplianceReport import ComplianceReport | ||
|
@@ -24,6 +26,27 @@ def mock_user_has_roles(): | |
yield mock | ||
|
||
|
||
@pytest.fixture | ||
def mock_notification_service(): | ||
mock_service = AsyncMock(spec=NotificationService) | ||
with patch( | ||
"lcfs.web.api.compliance_report.update_service.Depends", | ||
return_value=mock_service | ||
): | ||
yield mock_service | ||
|
||
|
||
@pytest.fixture | ||
def mock_environment_vars(): | ||
with patch("lcfs.web.api.email.services.settings") as mock_settings: | ||
mock_settings.ches_auth_url = "http://mock_auth_url" | ||
mock_settings.ches_email_url = "http://mock_email_url" | ||
mock_settings.ches_client_id = "mock_client_id" | ||
mock_settings.ches_client_secret = "mock_client_secret" | ||
mock_settings.ches_sender_email = "[email protected]" | ||
mock_settings.ches_sender_name = "Mock Notification System" | ||
yield mock_settings | ||
|
||
# Mock for adjust_balance method within the OrganizationsService | ||
@pytest.fixture | ||
def mock_org_service(): | ||
|
@@ -35,7 +58,7 @@ def mock_org_service(): | |
# update_compliance_report | ||
@pytest.mark.anyio | ||
async def test_update_compliance_report_status_change( | ||
compliance_report_update_service, mock_repo | ||
compliance_report_update_service, mock_repo, mock_notification_service | ||
): | ||
# Mock data | ||
report_id = 1 | ||
|
@@ -55,6 +78,7 @@ async def test_update_compliance_report_status_change( | |
mock_repo.get_compliance_report_by_id.return_value = mock_report | ||
mock_repo.get_compliance_report_status_by_desc.return_value = new_status | ||
compliance_report_update_service.handle_status_change = AsyncMock() | ||
compliance_report_update_service.notfn_service = mock_notification_service | ||
mock_repo.update_compliance_report.return_value = mock_report | ||
|
||
# Call the method | ||
|
@@ -80,6 +104,7 @@ async def test_update_compliance_report_status_change( | |
|
||
assert mock_report.current_status == new_status | ||
assert mock_report.supplemental_note == report_data.supplemental_note | ||
mock_notification_service.send_notification.assert_called_once() | ||
|
||
|
||
@pytest.mark.anyio | ||
|
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
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
Oops, something went wrong.