feat: unassociated credit trade calculations, credit validation script #1539
GitHub Actions / Backend Test Results
succeeded
Dec 17, 2024 in 0s
2 fail, 491 pass in 1m 53s
Annotations
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 0x7f530d7f9de0>
fastapi_app = <fastapi.applications.FastAPI object at 0x7f5307d492a0>
set_mock_user = <function set_mock_user.<locals>._set_mock_auth at 0x7f5307226a70>
add_models = <function add_models.<locals>._add at 0x7f5307895480>
@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 0x7f530c135870>
fastapi_app = <fastapi.applications.FastAPI object at 0x7f530c81dd20>
set_mock_user = <function set_mock_user.<locals>._set_mock_auth at 0x7f530788c3a0>
add_models = <function add_models.<locals>._add at 0x7f530773cf70>
@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
Loading