-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d37b813
commit b84a538
Showing
21 changed files
with
804 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM python:3.10.4-buster | ||
FROM python:3.10.13-buster | ||
|
||
WORKDIR /opt/project | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,111 @@ | ||
from collections import namedtuple | ||
from unittest.mock import patch | ||
|
||
import pytest | ||
from django.test import override_settings | ||
|
||
from thenewboston.discord.bot import on_ready | ||
from thenewboston.discord.bot import messages_to_structured, on_ready | ||
|
||
Author = namedtuple('Author', ['id']) | ||
Message = namedtuple('Message', ['author', 'content']) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_on_ready(): | ||
with patch('thenewboston.discord.bot.bot'): | ||
await on_ready() | ||
|
||
|
||
@override_settings(IA_DISCORD_USER_ID=1234) | ||
def test_messages_to_structured(): | ||
assert messages_to_structured([Message(author=Author(id=1234), content='hello')]) == [{ | ||
'role': 'assistant', | ||
'content': [{ | ||
'type': 'text', | ||
'text': 'hello' | ||
}] | ||
}] | ||
assert messages_to_structured([ | ||
Message(author=Author(id=1234), content='hello'), | ||
Message(author=Author(id=1234), content='world') | ||
]) == [{ | ||
'role': 'assistant', | ||
'content': [{ | ||
'type': 'text', | ||
'text': 'hello\nworld' | ||
}] | ||
}] | ||
assert messages_to_structured([ | ||
Message(author=Author(id=1234), content='hello'), | ||
Message(author=Author(id=10), content='world') | ||
]) == [ | ||
{ | ||
'role': 'assistant', | ||
'content': [{ | ||
'type': 'text', | ||
'text': 'hello' | ||
}] | ||
}, | ||
{ | ||
'role': 'user', | ||
'content': [{ | ||
'type': 'text', | ||
'text': 'world' | ||
}] | ||
}, | ||
] | ||
assert messages_to_structured([ | ||
Message(author=Author(id=1234), content='hello'), | ||
Message(author=Author(id=10), content='world'), | ||
Message(author=Author(id=1234), content='bye') | ||
]) == [ | ||
{ | ||
'role': 'assistant', | ||
'content': [{ | ||
'type': 'text', | ||
'text': 'hello' | ||
}] | ||
}, | ||
{ | ||
'role': 'user', | ||
'content': [{ | ||
'type': 'text', | ||
'text': 'world' | ||
}] | ||
}, | ||
{ | ||
'role': 'assistant', | ||
'content': [{ | ||
'type': 'text', | ||
'text': 'bye' | ||
}] | ||
}, | ||
] | ||
assert messages_to_structured([ | ||
Message(author=Author(id=1234), content='hello'), | ||
Message(author=Author(id=10), content='world'), | ||
Message(author=Author(id=10), content='mine'), | ||
Message(author=Author(id=1234), content='bye') | ||
]) == [ | ||
{ | ||
'role': 'assistant', | ||
'content': [{ | ||
'type': 'text', | ||
'text': 'hello' | ||
}] | ||
}, | ||
{ | ||
'role': 'user', | ||
'content': [{ | ||
'type': 'text', | ||
'text': 'world\nmine' | ||
}] | ||
}, | ||
{ | ||
'role': 'assistant', | ||
'content': [{ | ||
'type': 'text', | ||
'text': 'bye' | ||
}] | ||
}, | ||
] |
Oops, something went wrong.