Skip to content
Permalink
Browse files

fix: EFBChat initialised with middleware does not produce channel_emo…

…ji property.
  • Loading branch information
blueset committed Jan 3, 2020
1 parent b062eb5 commit 062148e19eb75b1755d7566e1f7cda60c73ffa02
Showing with 24 additions and 13 deletions.
  1. +5 −5 .travis.yml
  2. +1 −1 ehforwarderbot/__version__.py
  3. +3 −1 ehforwarderbot/chat.py
  4. +15 −6 tests/test_chat.py
@@ -1,12 +1,12 @@
dist: xenial
dist: bionic
language: python
cache: pip
python:
- 3.6
- 3.7
- 3.8
install:
- pip install -Ue .
- pip install -U pytest mypy 1a23_telemetry doit coverage
- pip install -Ue '.[tests]'
script:
- doit mypy
- doit test
- mypy -p ehforwarderbot
- pytest -vv -r a -l --color=yes
@@ -1,3 +1,3 @@
# coding=utf-8

__version__ = "2.0.0b24"
__version__ = "2.0.0b25.dev1"
@@ -44,7 +44,8 @@ class EFBChat:
Attributes:
module_id (str): Unique ID of the module.
channel_emoji (str): Emoji of the channel, if available.
channel_emoji (str): Emoji of the channel, empty string if the chat
is from a middleware.
module_name (str): Name of the module.
chat_name (str): Name of the chat.
chat_alias (Optional[str]): Alternative name of the chat, usually set by user.
@@ -106,6 +107,7 @@ def __init__(self, channel: Optional[EFBChannel] = None,
elif isinstance(middleware, EFBMiddleware):
self.module_id = middleware.middleware_id
self.module_name = middleware.middleware_name
self.channel_emoji = ""
else:
self.module_name = module_name
self.channel_emoji = channel_emoji
@@ -6,7 +6,7 @@


def test_generate_with_channel(slave_channel):
chat = EFBChat(slave_channel)
chat = EFBChat(channel=slave_channel)
assert chat.module_id == slave_channel.channel_id
assert chat.module_name == slave_channel.channel_name
assert chat.channel_emoji == slave_channel.channel_emoji
@@ -35,7 +35,7 @@ def test_normal_chat():


def test_copy(slave_channel):
chat = EFBChat(slave_channel)
chat = EFBChat(channel=slave_channel)
chat.chat_uid = "00001"
chat.chat_name = "Chat"
chat.chat_alias = "chaT"
@@ -46,7 +46,16 @@ def test_copy(slave_channel):


def test_verify_valid_chat(slave_channel):
chat = EFBChat(slave_channel)
chat = EFBChat(channel=slave_channel)
chat.chat_uid = "00001"
chat.chat_name = "Chat"
chat.chat_alias = "chaT"
chat.chat_type = ChatType.User
chat.verify()


def test_verify_valid_chat_middleware(middleware):
chat = EFBChat(middleware=middleware)
chat.chat_uid = "00001"
chat.chat_name = "Chat"
chat.chat_alias = "chaT"
@@ -55,15 +64,15 @@ def test_verify_valid_chat(slave_channel):


def test_verify_missing_uid(slave_channel):
chat = EFBChat(slave_channel)
chat = EFBChat(channel=slave_channel)
chat.chat_name = "Chat"
chat.chat_type = ChatType.User
with pytest.raises(ValueError):
chat.verify()


def test_verify_wrong_chat_type(slave_channel):
chat = EFBChat(slave_channel)
chat = EFBChat(channel=slave_channel)
chat.chat_uid = "00001"
chat.chat_name = "Chat"
chat.chat_type = "user"
@@ -72,7 +81,7 @@ def test_verify_wrong_chat_type(slave_channel):


def test_pickle(slave_channel):
chat = EFBChat(slave_channel)
chat = EFBChat(channel=slave_channel)
chat.chat_uid = "00001"
chat.chat_name = "Chat"
chat.chat_alias = "chaT"

0 comments on commit 062148e

Please sign in to comment.
You can’t perform that action at this time.