PoeTrade/tests/test_messages.py

96 lines
4.4 KiB
Python

from datetime import datetime
from src import config, data
from src.data import Channel
def test_message_from():
conf = config.read_config(r'config.yaml')
data.compile_regex(conf)
text = '2021/03/08 23:24:52 17931875 bb3 [INFO Client 1492] @From NyhaiPuki: Hi, I would like to buy your level 21 23% Vaal Impurity of Lightning ' \
'listed for 18 chaos in Ritual (stash tab "$"; position: left 22, top 5)'
message = data.Message.from_text(text)
assert message
assert message.communication
assert message.communication.user == 'NyhaiPuki'
assert message.communication.message == 'Hi, I would like to buy your level 21 23% Vaal Impurity of Lightning ' \
'listed for 18 chaos in Ritual (stash tab "$"; position: left 22, top 5)'
assert message.date == datetime(2021, 3, 8, 23, 24, 52)
assert message.communication.channel == Channel.WHISPER
assert message.communication.guild is None
assert message.communication.to_from == 'From'
assert message.communication.trade
assert message.communication.trade.amount == 18
assert message.communication.trade.col == 22
assert message.communication.trade.row == 5
assert message.communication.trade.currency == 'chaos'
assert message.communication.trade.item == 'level 21 23% Vaal Impurity of Lightning'
assert message.communication.trade.league == 'Ritual'
def test_message_from_float():
conf = config.read_config(r'config.yaml')
data.compile_regex(conf)
text = '2023/01/02 23:57:26 15123437 cffb0734 [INFO Client 16668] @From <SETSU?> LASTTRYPOEenjoyer: ' \
'Hi, I would like to buy your Watcher\'s Eye, Prismatic Jewel listed for 2.5 divine in Sanctum (stash tab "$2"; position: left 8, top 7)'
message = data.Message.from_text(text)
assert message
assert message.communication
assert message.communication.user == 'LASTTRYPOEenjoyer'
assert message.communication.message == 'Hi, I would like to buy your Watcher\'s Eye, Prismatic Jewel listed for 2.5 divine' \
' in Sanctum (stash tab "$2"; position: left 8, top 7)'
assert message.date == datetime(2023, 1, 2, 23, 57, 26)
assert message.communication.channel == Channel.WHISPER
assert message.communication.guild == 'SETSU?'
assert message.communication.to_from == 'From'
assert message.communication.trade
assert message.communication.trade.amount == 2.5
assert message.communication.trade.col == 8
assert message.communication.trade.row == 7
assert message.communication.trade.currency == 'divine'
assert message.communication.trade.item == 'Watcher\'s Eye, Prismatic Jewel'
assert message.communication.trade.league == 'Sanctum'
def test_entered():
conf = config.read_config(r'config.yaml')
data.compile_regex(conf)
text = r'2023/05/07 18:18:03 35114562 cffb0719 [INFO Client 6416] : Oathussy has joined the area.'
message = data.Message.from_text(text)
assert message
assert message.entered
assert message.entered.user == 'Oathussy'
def test_message_to():
conf = config.read_config(r'config.yaml')
data.compile_regex(conf)
text_to = '2021/01/24 23:11:23 17039703 bb2 [INFO Client 10144] @To EraseAndDelete: Thank you & good luck!'
message = data.Message.from_text(text_to)
assert message
assert message.communication
assert message.communication.user == 'EraseAndDelete'
assert message.communication.message == 'Thank you & good luck!'
assert message.date == datetime(2021, 1, 24, 23, 11, 23)
assert message.communication.channel == Channel.WHISPER
assert message.communication.guild is None
assert message.communication.to_from == 'To'
assert message.communication.trade is None
def test_message_global():
conf = config.read_config(r'config.yaml')
data.compile_regex(conf)
text_global = '2021/02/10 19:01:56 2720500 bb2 [INFO Client 3464] #HarvestScarab: so by the time it was finally juiced you couldnt do it'
message = data.Message.from_text(text_global)
assert message
assert message.communication
assert message.communication.user == 'HarvestScarab'
assert message.communication.message == 'so by the time it was finally juiced you couldnt do it'
assert message.date == datetime(2021, 2, 10, 19, 1, 56)
assert message.communication.channel == Channel.GLOBAL
assert message.communication.guild is None
assert message.communication.to_from is None
assert message.communication.trade is None