Supplier cannot add its own Organization as Legal Name Transaction Pa… #1438
3 fail, 495 pass in 1m 49s
498 tests 495 ✅ 1m 49s ⏱️
1 suites 0 💤
1 files 3 ❌
Results for commit 4b92952.
Annotations
Check warning on line 0 in lcfs.tests.compliance_report.test_summary_service
github-actions / Backend Test Results
test_calculate_fuel_quantities_renewable (lcfs.tests.compliance_report.test_summary_service) failed
backend/pytest-results.xml [took 0s]
Raw output
AssertionError: Expected aggregate_allocation_agreements to have been awaited once. Awaited 0 times.
compliance_report_summary_service = <lcfs.web.api.compliance_report.summary_service.ComplianceReportSummaryService object at 0x7f41d1895c60>
mock_repo = <AsyncMock spec='ComplianceReportRepository' id='139920664797552'>
mock_trxn_repo = <AsyncMock spec='TransactionRepository' id='139920665328608'>
mock_fuel_supply_repo = <AsyncMock spec='FuelSupplyRepository' id='139920665051088'>
@pytest.mark.anyio
async def test_calculate_fuel_quantities_renewable(
compliance_report_summary_service,
mock_repo,
mock_trxn_repo,
mock_fuel_supply_repo,
):
# Create a mock repository
mock_repo.aggregate_fuel_supplies.return_value = {"gasoline": 200.0}
mock_repo.aggregate_other_uses.return_value = {"diesel": 75.0}
mock_repo.aggregate_allocation_agreements.return_value = {"jet-fuel": 25.0}
# Define test inputs
compliance_report_id = 2
effective_fuel_supplies: List[FuelSupply] = []
fossil_derived = False
# Call the method under test
result = await compliance_report_summary_service.calculate_fuel_quantities(
compliance_report_id, effective_fuel_supplies, fossil_derived
)
# Assertions
mock_repo.aggregate_fuel_supplies.assert_called_once_with(
effective_fuel_supplies, fossil_derived
)
mock_repo.aggregate_other_uses.assert_awaited_once_with(
compliance_report_id, fossil_derived
)
> mock_repo.aggregate_allocation_agreements.assert_awaited_once_with(
compliance_report_id
)
lcfs/tests/compliance_report/test_summary_service.py:833:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <AsyncMock name='mock.aggregate_allocation_agreements' id='139920664695312'>
args = (2,), kwargs = {}
msg = 'Expected aggregate_allocation_agreements to have been awaited once. Awaited 0 times.'
def assert_awaited_once_with(self, /, *args, **kwargs):
"""
Assert that the mock was awaited exactly once and with the specified
arguments.
"""
if not self.await_count == 1:
msg = (f"Expected {self._mock_name or 'mock'} to have been awaited once."
f" Awaited {self.await_count} times.")
> raise AssertionError(msg)
E AssertionError: Expected aggregate_allocation_agreements to have been awaited once. Awaited 0 times.
/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/unittest/mock.py:2305: AssertionError
Check warning on line 0 in lcfs.tests.internal_comment.test_internal_comment
github-actions / Backend Test Results
test_get_internal_comments_multiple_comments (lcfs.tests.internal_comment.test_internal_comment) failed
backend/pytest-results.xml [took 0s]
Raw output
assert 0 == 3
+ where 0 = len([])
client = <httpx.AsyncClient object at 0x7f41d2d65ae0>
fastapi_app = <fastapi.applications.FastAPI object at 0x7f41d2a92680>
set_mock_user = <function set_mock_user.<locals>._set_mock_auth at 0x7f41d0762050>
add_models = <function add_models.<locals>._add at 0x7f41d072ca60>
@pytest.mark.anyio
async def test_get_internal_comments_multiple_comments(
client: AsyncClient,
fastapi_app: FastAPI,
set_mock_user,
add_models,
):
"""
Test retrieving multiple internal comments for an entity.
"""
set_mock_user(
fastapi_app, [RoleEnum.GOVERNMENT], user_details={"username": "IDIRUSER"}
)
transfer = Transfer(
transfer_id=5,
from_organization_id=1,
to_organization_id=2,
agreement_date=datetime.now(),
transaction_effective_date=datetime.now(),
price_per_unit=1.0,
quantity=100,
transfer_category_id=1,
current_status_id=1,
recommendation=TransferRecommendationEnum.Record,
effective_status=True,
)
await add_models([transfer])
comments = []
for i in range(3):
internal_comment = InternalComment(
internal_comment_id=i,
comment=f"Comment {i}",
audience_scope=AudienceScopeEnum.ANALYST.value,
create_user="IDIRUSER",
)
await add_models([internal_comment])
association = TransferInternalComment(
transfer_id=transfer.transfer_id,
internal_comment_id=internal_comment.internal_comment_id,
)
await add_models([association])
comments.append(internal_comment)
entity_type = EntityTypeEnum.TRANSFER.value
entity_id = transfer.transfer_id
url = fastapi_app.url_path_for(
"get_comments", entity_type=entity_type, entity_id=entity_id
)
response = await client.get(url)
assert response.status_code == status.HTTP_200_OK
data = response.json()
assert isinstance(data, list)
> assert len(data) == 3
E assert 0 == 3
E + where 0 = len([])
lcfs/tests/internal_comment/test_internal_comment.py:364: AssertionError
Check warning on line 0 in lcfs.tests.user.test_user_views
github-actions / Backend Test Results
test_get_user_activities_as_manage_users_same_org (lcfs.tests.user.test_user_views) failed
backend/pytest-results.xml [took 0s]
Raw output
assert 403 == 200
+ where 403 = <Response [403 Forbidden]>.status_code
+ and 200 = status.HTTP_200_OK
client = <httpx.AsyncClient object at 0x7f41d2d38310>
fastapi_app = <fastapi.applications.FastAPI object at 0x7f41d06342e0>
set_mock_user = <function set_mock_user.<locals>._set_mock_auth at 0x7f41cbdcf490>
add_models = <function add_models.<locals>._add at 0x7f41d20d6290>
@pytest.mark.anyio
async def test_get_user_activities_as_manage_users_same_org(
client: AsyncClient,
fastapi_app: FastAPI,
set_mock_user,
add_models,
):
# Mock the current user as a user with MANAGE_USERS
set_mock_user(fastapi_app, [RoleEnum.MANAGE_USERS])
# Assuming target user with user_profile_id=3 exists and is in organization_id=1
target_user_id = 1
# Create activity history records for the target user
transfer = Transfer(
transfer_id=1,
from_organization_id=1,
to_organization_id=2,
agreement_date=datetime.strptime("2024-01-01", "%Y-%m-%d"),
transaction_effective_date=datetime.strptime("2024-01-01", "%Y-%m-%d"),
price_per_unit=1.0,
quantity=10,
transfer_category_id=1,
current_status_id=1,
recommendation=TransferRecommendationEnum.Record,
effective_status=True,
)
transfer_history = TransferHistory(
transfer_history_id=1,
transfer_id=transfer.transfer_id,
transfer_status_id=3, # Sent
user_profile_id=target_user_id,
)
await add_models(
[
transfer,
transfer_history,
]
)
# Prepare request data
pagination = {
"page": 1,
"size": 10,
"filters": [],
"sortOrders": [],
}
# Send request to get user activities
url = fastapi_app.url_path_for("get_user_activities", user_id=target_user_id)
response = await client.post(url, json=pagination)
> assert response.status_code == status.HTTP_200_OK
E assert 403 == 200
E + where 403 = <Response [403 Forbidden]>.status_code
E + and 200 = status.HTTP_200_OK
lcfs/tests/user/test_user_views.py:173: AssertionError