Skip to content

Commit

Permalink
Add prepare_aleph_message test
Browse files Browse the repository at this point in the history
  • Loading branch information
MHHukiewitz committed Nov 27, 2023
1 parent 5ded5c3 commit b11349b
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions tests/unit/test_asynchronous.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import datetime
from unittest.mock import AsyncMock

import pytest as pytest
from aleph_message.models import (
AggregateMessage,
ForgetMessage,
InstanceMessage,
MessageType,
PostMessage,
ProgramMessage,
StoreMessage,
)
from aleph_message.models.execution.environment import MachineResources
from aleph_message.status import MessageStatus

from aleph.sdk.types import StorageEnum
Expand Down Expand Up @@ -121,3 +124,63 @@ async def test_forget(mock_session_with_post_success):

assert mock_session_with_post_success.http_session.post.called_once
assert isinstance(forget_message, ForgetMessage)


@pytest.mark.asyncio
@pytest.mark.parametrize(
"message_type, content",
[
(
MessageType.aggregate,
{
"content": {"Hello": datetime.datetime.now()},
"key": "test",
"address": "0x1",
"time": 1.0,
},
),
(
MessageType.aggregate,
{
"content": {"Hello": datetime.date.today()},
"key": "test",
"address": "0x1",
"time": 1.0,
},
),
(
MessageType.aggregate,
{
"content": {"Hello": datetime.time()},
"key": "test",
"address": "0x1",
"time": 1.0,
},
),
(
MessageType.aggregate,
{
"content": {
"Hello": MachineResources(
vcpus=1,
memory=1024,
seconds=1,
)
},
"key": "test",
"address": "0x1",
"time": 1.0,
},
),
],
)
async def test_prepare_aleph_message(
mock_session_with_post_success, message_type, content
):
# Call the function under test
async with mock_session_with_post_success as session:
await session._prepare_aleph_message(
message_type=message_type,
content=content,
channel="TEST",
)

0 comments on commit b11349b

Please sign in to comment.