Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions slackclient/_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ def __eq__(self, compare_str):
else:
return False

def __hash__(self):
return hash(self.id)

def __str__(self):
data = ""
for key in list(self.__dict__.keys()):
Expand Down
3 changes: 3 additions & 0 deletions slackclient/_im.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ def __eq__(self, compare_str):
else:
return False

def __hash__(self):
return hash(self.id)

def __str__(self):
data = ""
for key in list(self.__dict__.keys()):
Expand Down
3 changes: 3 additions & 0 deletions slackclient/_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ def __eq__(self, compare_str):
else:
return False

def __hash__(self):
return hash(self.token)

def __str__(self):
data = ""
for key in list(self.__dict__.keys()):
Expand Down
3 changes: 3 additions & 0 deletions slackclient/_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ def __eq__(self, compare_str):
else:
return False

def __hash__(self):
return hash(self.id)

def __str__(self):
data = ""
for key in list(self.__dict__.keys()):
Expand Down
10 changes: 10 additions & 0 deletions tests/test_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ def test_channel_eq(channel):
assert channel == 'C12345678'
assert (channel == 'foo') is False

def test_channel_is_hashable(channel):
channel = Channel(
'test-server',
'test-channel',
'C12345678',
)
channel_map = {channel: channel.id}
assert channel_map[channel] == 'C12345678'
assert (channel_map[channel] == 'foo') is False

@pytest.mark.xfail
def test_channel_send_message(channel):
channel.send_message('hi')
6 changes: 6 additions & 0 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ def test_Server(server):
assert type(server) == Server


def test_Server_is_hashable(server):
server_map = {server: server.token}
assert server_map[server] == 'xoxp-1234123412341234-12341234-1234'
assert (server_map[server] == 'foo') is False


def test_Server_parse_channel_data(server, login_fixture):
server.parse_channel_data(login_fixture["channels"])
assert type(server.channels.find('general')) == Channel
Expand Down