Skip to content

Commit 062148e

Browse files
committed
fix: EFBChat initialised with middleware does not produce channel_emoji property.
1 parent b062eb5 commit 062148e

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

Diff for: .travis.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
dist: xenial
1+
dist: bionic
22
language: python
33
cache: pip
44
python:
55
- 3.6
66
- 3.7
7+
- 3.8
78
install:
8-
- pip install -Ue .
9-
- pip install -U pytest mypy 1a23_telemetry doit coverage
9+
- pip install -Ue '.[tests]'
1010
script:
11-
- doit mypy
12-
- doit test
11+
- mypy -p ehforwarderbot
12+
- pytest -vv -r a -l --color=yes

Diff for: ehforwarderbot/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# coding=utf-8
22

3-
__version__ = "2.0.0b24"
3+
__version__ = "2.0.0b25.dev1"

Diff for: ehforwarderbot/chat.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ class EFBChat:
4444
4545
Attributes:
4646
module_id (str): Unique ID of the module.
47-
channel_emoji (str): Emoji of the channel, if available.
47+
channel_emoji (str): Emoji of the channel, empty string if the chat
48+
is from a middleware.
4849
module_name (str): Name of the module.
4950
chat_name (str): Name of the chat.
5051
chat_alias (Optional[str]): Alternative name of the chat, usually set by user.
@@ -106,6 +107,7 @@ def __init__(self, channel: Optional[EFBChannel] = None,
106107
elif isinstance(middleware, EFBMiddleware):
107108
self.module_id = middleware.middleware_id
108109
self.module_name = middleware.middleware_name
110+
self.channel_emoji = ""
109111
else:
110112
self.module_name = module_name
111113
self.channel_emoji = channel_emoji

Diff for: tests/test_chat.py

+15-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

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

3636

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

4747

4848
def test_verify_valid_chat(slave_channel):
49-
chat = EFBChat(slave_channel)
49+
chat = EFBChat(channel=slave_channel)
50+
chat.chat_uid = "00001"
51+
chat.chat_name = "Chat"
52+
chat.chat_alias = "chaT"
53+
chat.chat_type = ChatType.User
54+
chat.verify()
55+
56+
57+
def test_verify_valid_chat_middleware(middleware):
58+
chat = EFBChat(middleware=middleware)
5059
chat.chat_uid = "00001"
5160
chat.chat_name = "Chat"
5261
chat.chat_alias = "chaT"
@@ -55,15 +64,15 @@ def test_verify_valid_chat(slave_channel):
5564

5665

5766
def test_verify_missing_uid(slave_channel):
58-
chat = EFBChat(slave_channel)
67+
chat = EFBChat(channel=slave_channel)
5968
chat.chat_name = "Chat"
6069
chat.chat_type = ChatType.User
6170
with pytest.raises(ValueError):
6271
chat.verify()
6372

6473

6574
def test_verify_wrong_chat_type(slave_channel):
66-
chat = EFBChat(slave_channel)
75+
chat = EFBChat(channel=slave_channel)
6776
chat.chat_uid = "00001"
6877
chat.chat_name = "Chat"
6978
chat.chat_type = "user"
@@ -72,7 +81,7 @@ def test_verify_wrong_chat_type(slave_channel):
7281

7382

7483
def test_pickle(slave_channel):
75-
chat = EFBChat(slave_channel)
84+
chat = EFBChat(channel=slave_channel)
7685
chat.chat_uid = "00001"
7786
chat.chat_name = "Chat"
7887
chat.chat_alias = "chaT"

0 commit comments

Comments
 (0)