Skip to content

Commit

Permalink
Review comment fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
ihsandemir committed Jan 4, 2024
1 parent 64ed90b commit 3883500
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions tests/integration/backward_compatible/proxy/reliable_topic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from hazelcast.proxy.base import TopicMessage
from hazelcast.types import MessageType
from hazelcast.util import AtomicInteger

from tests.hzrc.ttypes import Lang

Expand Down Expand Up @@ -88,7 +89,7 @@ def test_add_listener(self):

messages = []

on_cancel_call_count = [0]
on_cancel_call_count = AtomicInteger()

class Listener(ReliableMessageListener):
def on_message(self, message):
Expand All @@ -107,7 +108,7 @@ def is_terminal(self, error):
return False

def on_cancel(self):
on_cancel_call_count[0] = on_cancel_call_count[0] + 1
on_cancel_call_count.add(1)

registration_id = topic.add_listener(Listener())
self.assertIsNotNone(registration_id)
Expand All @@ -117,7 +118,7 @@ def on_cancel(self):

self.assertTrueEventually(lambda: self.assertEqual(["a", "b"], messages))

self.assertEqual(0, on_cancel_call_count[0])
self.assertEqual(0, on_cancel_call_count.get())

def test_add_listener_with_retrieve_initial_sequence(self):
topic = self.get_topic(random_string())
Expand Down Expand Up @@ -243,7 +244,7 @@ def test_add_listener_when_on_message_raises_error(self):

messages = []

on_cancel_call_count = [0]
on_cancel_call_count = AtomicInteger()

class Listener(ReliableMessageListener):
def on_message(self, message):
Expand All @@ -266,7 +267,7 @@ def is_terminal(self, error):
return isinstance(error, ValueError)

def on_cancel(self) -> None:
on_cancel_call_count[0] = on_cancel_call_count[0] + 1
on_cancel_call_count.add(1)

registration_id = topic.add_listener(Listener())
self.assertIsNotNone(registration_id)
Expand All @@ -278,14 +279,14 @@ def on_cancel(self) -> None:
# Should be cancelled since on_message raised error
self.assertTrueEventually(lambda: self.assertEqual(0, len(topic._wrapped._runners)))

self.assertEqual(1, on_cancel_call_count[0])
self.assertEqual(1, on_cancel_call_count.get())

def test_add_listener_when_on_message_and_is_terminal_raises_error(self):
topic = self.get_topic(random_string())

messages = []

on_cancel_call_count = [0]
on_cancel_call_count = AtomicInteger()

class Listener(ReliableMessageListener):
def on_message(self, message):
Expand All @@ -308,7 +309,7 @@ def is_terminal(self, error):
raise error

def on_cancel(self) -> None:
on_cancel_call_count[0] = on_cancel_call_count[0] + 1
on_cancel_call_count.add(1)

registration_id = topic.add_listener(Listener())
self.assertIsNotNone(registration_id)
Expand All @@ -320,7 +321,7 @@ def on_cancel(self) -> None:
# Should be cancelled since on_message raised error
self.assertTrueEventually(lambda: self.assertEqual(0, len(topic._wrapped._runners)))

self.assertEqual(1, on_cancel_call_count[0])
self.assertEqual(1, on_cancel_call_count.get())

def test_add_listener_with_non_callable(self):
topic = self.get_topic(random_string())
Expand All @@ -330,7 +331,7 @@ def test_add_listener_with_non_callable(self):
def test_remove_listener(self):
topic = self.get_topic(random_string())

on_cancel_call_count = [0]
on_cancel_call_count = AtomicInteger()

class Listener(ReliableMessageListener):
def on_message(self, message: TopicMessage[MessageType]) -> None:
Expand All @@ -349,11 +350,11 @@ def is_terminal(self, error: Exception) -> bool:
pass

def on_cancel(self) -> None:
on_cancel_call_count[0] = on_cancel_call_count[0] + 1
on_cancel_call_count.add(1)

registration_id = topic.add_listener(Listener())
self.assertTrue(topic.remove_listener(registration_id))
self.assertEqual(1, on_cancel_call_count[0])
self.assertEqual(1, on_cancel_call_count.get())

def test_remove_listener_does_not_receive_messages_after_removal(self):
topic = self.get_topic(random_string())
Expand Down

0 comments on commit 3883500

Please sign in to comment.