Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
leej3 committed Sep 9, 2024
1 parent 0d2a1f1 commit 027212d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import asyncio
import datetime

import nest_asyncio
import pytest
from motor.motor_asyncio import AsyncIOMotorClient
from odmantic import AIOEngine

from osm.schemas import Client, Component, Invocation, Work

nest_asyncio.apply()


@pytest.fixture(scope="function")
def test_engine():
Expand All @@ -17,8 +21,8 @@ def test_engine():
client.close()


@pytest.mark.asyncio
async def test_engine_save(test_engine):
# @pytest.mark.asyncio
def test_engine_save(test_engine):
# Create a sample invocation object
sample_invocation = Invocation(
work=Work(filename="test_file"),
Expand All @@ -32,17 +36,17 @@ async def test_engine_save(test_engine):
)

# Save the sample invocation to the database
await test_engine.save(sample_invocation)
asyncio.run(test_engine.save(sample_invocation))

# Retrieve the saved invocation to verify it was saved correctly
saved_invocation = await test_engine.find_one(
saved_invocation = test_engine.find_one(
Invocation, Invocation.id == sample_invocation.id
)
assert saved_invocation is not None, "Saved invocation not found"
assert saved_invocation.id == sample_invocation.id, "IDs do not match"

# Retrieve the saved invocation to verify it was saved correctly
saved_invocation = await test_engine.find_one(
saved_invocation = test_engine.find_one(
Invocation, Invocation.id == sample_invocation.id
)
assert saved_invocation is not None, "Saved invocation not found"
Expand Down

0 comments on commit 027212d

Please sign in to comment.