Skip to content

Commit

Permalink
Mock out qsize in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
coretl committed Oct 27, 2016
1 parent 7e26ba1 commit cd2a831
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/test_core/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def test_get(self):
request = Get(MagicMock(), MagicMock(), ["myblock", "path_1", "path_2"])
p._handle_block_add(BlockAdd(block, "myblock"))
p.q.get = MagicMock(side_effect=[request, PROCESS_STOP])
p.q.qsize.return_value = 0

p.recv_loop()

Expand Down Expand Up @@ -177,6 +178,7 @@ def test_subscribe(self):
sub_2 = Subscribe(
MagicMock(), MagicMock(), ["block", "inner"], True)
p.q.get = MagicMock(side_effect=[sub_1, sub_2, PROCESS_STOP])
p.q.qsize.return_value = 0

p._handle_block_add(BlockAdd(block, "block"))
p.recv_loop()
Expand Down Expand Up @@ -244,6 +246,7 @@ def test_unsubscribe(self):

p.q.get = MagicMock(side_effect=[sub_1, sub_2, change_1,
unsub_1, change_2, PROCESS_STOP])
p.q.qsize.return_value = 0
p._handle_block_add(BlockAdd(block, "block"))
p.recv_loop()

Expand All @@ -265,6 +268,7 @@ def test_unsubscribe_error(self):
unsub = Unsubscribe(MagicMock(), MagicMock())
unsub.set_id(1234)
p.q.get = MagicMock(side_effect=[unsub, PROCESS_STOP])
p.q.qsize.return_value = 0

p.recv_loop()

Expand Down
1 change: 1 addition & 0 deletions tests/test_core/test_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class TestRequest(unittest.TestCase):
def setUp(self):
self.context = MagicMock()
self.response_queue = MagicMock()
self.response_queue.qsize.return_value = 0
self.request = Request(self.context, self.response_queue)

def test_init(self):
Expand Down

0 comments on commit cd2a831

Please sign in to comment.