Add missing await #1594
GitHub Actions / Backend Test Results
succeeded
Dec 18, 2024 in 0s
1 fail, 501 pass in 1m 59s
Annotations
Check warning on line 0 in lcfs.tests.fuel_export.test_fuel_exports_repo
github-actions / Backend Test Results
test_update_fuel_export_success (lcfs.tests.fuel_export.test_fuel_exports_repo) failed
backend/pytest-results.xml [took 0s]
Raw output
lcfs.web.exception.exceptions.DatabaseException
args = (<lcfs.web.api.fuel_export.repo.FuelExportRepository object at 0x7f78b575d5a0>, <FuelExport(id=1, quantity=None)>)
kwargs = {}
logger = <BoundLoggerLazyProxy(logger=None, wrapper_class=None, processors=None, context_class=None, initial_values={}, logger_factory_args=('lcfs.web.api.fuel_export.repo',))>
context = {'local_vars': {'self': '<Handle <TaskStepMethWrapper object at 0x7f78b55dcee0>()>'}, 'request': {'headers': None, 'method': None, 'url': None}, 'session_state': 'No session', 'user': {'id': None, 'roles': []}}
new_exception = DatabaseException()
@wraps(func)
async def wrapper(*args, **kwargs):
logger = structlog.get_logger(func.__module__)
try:
> return await func(*args, **kwargs)
lcfs/web/core/decorators.py:241:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <lcfs.web.api.fuel_export.repo.FuelExportRepository object at 0x7f78b575d5a0>
fuel_export = <FuelExport(id=1, quantity=None)>
@repo_handler
async def update_fuel_export(self, fuel_export: FuelExport) -> FuelExport:
"""
Update an existing fuel supply row in the database.
"""
> updated_fuel_export = await self.db.merge(fuel_export)
E TypeError: object FuelExport can't be used in 'await' expression
lcfs/web/api/fuel_export/repo.py:236: TypeError
The above exception was the direct cause of the following exception:
fuel_export_repo = <lcfs.web.api.fuel_export.repo.FuelExportRepository object at 0x7f78b575d5a0>
mock_db = <AsyncMock spec='AsyncSession' id='140156323408496'>
@pytest.mark.anyio
async def test_update_fuel_export_success(fuel_export_repo, mock_db):
fuel_export = FuelExport(
fuel_export_id=1,
group_uuid="test-uuid",
version=1,
user_type=UserTypeEnum.SUPPLIER,
action_type=ActionTypeEnum.UPDATE,
)
updated_fuel_export = FuelExport(fuel_export_id=1)
mock_db.merge = MagicMock(return_value=updated_fuel_export)
mock_db.flush = AsyncMock()
mock_db.refresh = AsyncMock()
> result = await fuel_export_repo.update_fuel_export(fuel_export)
lcfs/tests/fuel_export/test_fuel_exports_repo.py:221:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
lcfs/web/core/decorators.py:251: in wrapper
raise new_exception.with_traceback(e.__traceback__) from e
lcfs/web/core/decorators.py:241: in wrapper
return await func(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <lcfs.web.api.fuel_export.repo.FuelExportRepository object at 0x7f78b575d5a0>
fuel_export = <FuelExport(id=1, quantity=None)>
@repo_handler
async def update_fuel_export(self, fuel_export: FuelExport) -> FuelExport:
"""
Update an existing fuel supply row in the database.
"""
> updated_fuel_export = await self.db.merge(fuel_export)
E lcfs.web.exception.exceptions.DatabaseException
lcfs/web/api/fuel_export/repo.py:236: DatabaseException
Loading