Skip to content

Commit 430641a

Browse files
author
fkromer
committed
add:
- test "subscriber detachable from subscription" change: - refactoring of test names - test "subscriber attachable to subscription"
1 parent e9619ad commit 430641a

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

test_publish_subscribe.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,24 @@ class TestProvider(unittest.TestCase):
1616
"""
1717
Integration tests ~ provider class with as little mocking as possible.
1818
"""
19-
def test_subscriber_shall_be_attachable(cls):
19+
def test_subscriber_shall_be_attachable_to_subscriptions(cls):
20+
subscription = 'sub msg'
2021
pro = Provider()
2122
cls.assertEqual(len(pro.subscribers), 0)
2223
sub = Subscriber('sub name', pro)
23-
sub.subscribe('sub msg')
24-
cls.assertEqual(len(pro.subscribers), 1)
24+
sub.subscribe(subscription)
25+
cls.assertEqual(len(pro.subscribers[subscription]), 1)
2526

26-
# def test_subscriber_shall_be_detachable(cls):
27-
# pro = Provider()
28-
# sub = Subscriber('sub name', pro)
29-
# sub.subscribe('sub msg')
30-
# cls.assertEqual(len(pro.subscribers), 1)
31-
# pro.unsubscribe('sub msg', sub)
32-
# cls.assertEqual(len(pro.subscribers), 0)
27+
def test_subscriber_shall_be_detachable_from_subscriptions(cls):
28+
subscription = 'sub msg'
29+
pro = Provider()
30+
sub = Subscriber('sub name', pro)
31+
sub.subscribe(subscription)
32+
cls.assertEqual(len(pro.subscribers[subscription]), 1)
33+
sub.unsubscribe(subscription)
34+
cls.assertEqual(len(pro.subscribers[subscription]), 0)
3335

34-
def test_publisher_shall_append_message(cls):
36+
def test_publisher_shall_append_subscription_message_to_queue(cls):
3537
''' msg_queue ~ Provider.notify(msg) ~ Publisher.publish(msg) '''
3638
expected_msg = 'expected msg'
3739
pro = Provider()
@@ -42,7 +44,7 @@ def test_publisher_shall_append_message(cls):
4244
cls.assertEqual(len(pro.msg_queue), 1)
4345
cls.assertEqual(pro.msg_queue[0], expected_msg)
4446

45-
def test_provider_shall_update_affected_subscribers_with_published_messages(cls):
47+
def test_provider_shall_update_affected_subscribers_with_published_subscription(cls):
4648
pro = Provider()
4749
pub = Publisher(pro)
4850
sub1 = Subscriber('sub 1 name', pro)

0 commit comments

Comments
 (0)