Skip to content
Snippets Groups Projects
Commit cf1b6740 authored by Jan David Mol's avatar Jan David Mol
Browse files

L2SS-340: Remove queue parameter from TCPReplicator

parent 45b2f370
Branches
Tags
1 merge request!117create TCPReplicator for StatisticsClient
...@@ -31,8 +31,6 @@ class TestTCPReplicator(base.TestCase): ...@@ -31,8 +31,6 @@ class TestTCPReplicator(base.TestCase):
def setUp(self): def setUp(self):
super(TestTCPReplicator, self).setUp() super(TestTCPReplicator, self).setUp()
self.m_queue = mock.Mock()
self.m_server = mock.Mock() self.m_server = mock.Mock()
self.m_server.wait_closed.return_value = self.dummy_task() self.m_server.wait_closed.return_value = self.dummy_task()
...@@ -71,7 +69,7 @@ class TestTCPReplicator(base.TestCase): ...@@ -71,7 +69,7 @@ class TestTCPReplicator(base.TestCase):
"tcp_bind": '0.0.0.0', # I should get set "tcp_bind": '0.0.0.0', # I should get set
} }
replicator = self.m_tcp_replicator(self.m_queue, test_options) replicator = self.m_tcp_replicator(options=test_options)
self.assertTrue(replicator.is_alive()) self.assertTrue(replicator.is_alive())
# Ensure replicator initialization does not modify static variable # Ensure replicator initialization does not modify static variable
...@@ -89,7 +87,7 @@ class TestTCPReplicator(base.TestCase): ...@@ -89,7 +87,7 @@ class TestTCPReplicator(base.TestCase):
m_client = mock.Mock() m_client = mock.Mock()
# Create both a TCPReplicator and TCPServerProtocol separately # Create both a TCPReplicator and TCPServerProtocol separately
replicator = self.m_tcp_replicator(self.m_queue) replicator = self.m_tcp_replicator()
self.assertTrue(replicator.is_alive()) self.assertTrue(replicator.is_alive())
protocol = TCPReplicator.TCPServerProtocol( protocol = TCPReplicator.TCPServerProtocol(
replicator._options, replicator._connected_clients) replicator._options, replicator._connected_clients)
...@@ -103,7 +101,7 @@ class TestTCPReplicator(base.TestCase): ...@@ -103,7 +101,7 @@ class TestTCPReplicator(base.TestCase):
def test_start_stop(self): def test_start_stop(self):
"""Verify threading behavior, being able to start and stop the thread""" """Verify threading behavior, being able to start and stop the thread"""
replicator = self.m_tcp_replicator(self.m_queue) replicator = self.m_tcp_replicator()
self.assertTrue(replicator.is_alive()) self.assertTrue(replicator.is_alive())
# Give the thread 5 seconds to stop # Give the thread 5 seconds to stop
...@@ -129,7 +127,7 @@ class TestTCPReplicator(base.TestCase): ...@@ -129,7 +127,7 @@ class TestTCPReplicator(base.TestCase):
run_patcher.new_event_loop.return_value = m_loop run_patcher.new_event_loop.return_value = m_loop
# Constructor should raise an exception if the thread dies early # Constructor should raise an exception if the thread dies early
self.assertRaises(RuntimeError, self.m_tcp_replicator, self.m_queue) self.assertRaises(RuntimeError, self.m_tcp_replicator)
@timeout_decorator.timeout(5) @timeout_decorator.timeout(5)
def test_start_except_server(self): def test_start_except_server(self):
...@@ -139,13 +137,13 @@ class TestTCPReplicator(base.TestCase): ...@@ -139,13 +137,13 @@ class TestTCPReplicator(base.TestCase):
RuntimeError("Test Error") RuntimeError("Test Error")
# Constructor should raise an exception if the thread dies early # Constructor should raise an exception if the thread dies early
self.assertRaises(RuntimeError, self.m_tcp_replicator, self.m_queue) self.assertRaises(RuntimeError, self.m_tcp_replicator)
@timeout_decorator.timeout(5) @timeout_decorator.timeout(5)
def test_start_stop_delete(self): def test_start_stop_delete(self):
"""Verify that deleting the TCPReplicator object safely halts thread""" """Verify that deleting the TCPReplicator object safely halts thread"""
replicator = self.m_tcp_replicator(self.m_queue) replicator = self.m_tcp_replicator()
self.assertTrue(replicator.is_alive()) self.assertTrue(replicator.is_alive())
del replicator del replicator
...@@ -157,7 +155,7 @@ class TestTCPReplicator(base.TestCase): ...@@ -157,7 +155,7 @@ class TestTCPReplicator(base.TestCase):
m_client = mock.Mock() m_client = mock.Mock()
replicator = self.m_tcp_replicator(self.m_queue) replicator = self.m_tcp_replicator()
self.assertTrue(replicator.is_alive()) self.assertTrue(replicator.is_alive())
replicator._connected_clients.append(m_client) replicator._connected_clients.append(m_client)
...@@ -176,7 +174,7 @@ class TestTCPReplicator(base.TestCase): ...@@ -176,7 +174,7 @@ class TestTCPReplicator(base.TestCase):
m_client.transport.write.assert_called_once_with(m_data) m_client.transport.write.assert_called_once_with(m_data)
def test_queue_start(self): def test_queue_start(self):
replicator = self.m_tcp_replicator(self.m_queue) replicator = self.m_tcp_replicator()
self.m_process_queue.assert_called_once_with(replicator) self.m_process_queue.assert_called_once_with(replicator)
...@@ -185,9 +183,7 @@ class TestTCPReplicator(base.TestCase): ...@@ -185,9 +183,7 @@ class TestTCPReplicator(base.TestCase):
m_client = mock.Mock() m_client = mock.Mock()
t_queue = Queue() replicator = self.m_tcp_replicator()
replicator = self.m_tcp_replicator(t_queue)
self.assertTrue(replicator.is_alive()) self.assertTrue(replicator.is_alive())
# Patch _process_queue back into object and jump start it # Patch _process_queue back into object and jump start it
...@@ -197,7 +193,7 @@ class TestTCPReplicator(base.TestCase): ...@@ -197,7 +193,7 @@ class TestTCPReplicator(base.TestCase):
replicator._connected_clients.append(m_client) replicator._connected_clients.append(m_client)
t_queue.put(m_data) replicator.put(m_data)
# TODO(Corne): Find suitable primitive to synchronize async task update # TODO(Corne): Find suitable primitive to synchronize async task update
# with main thread. # with main thread.
...@@ -213,7 +209,7 @@ class TestTCPReplicator(base.TestCase): ...@@ -213,7 +209,7 @@ class TestTCPReplicator(base.TestCase):
def test_disconnect(self,): def test_disconnect(self,):
m_client = mock.Mock() m_client = mock.Mock()
replicator = self.m_tcp_replicator(self.m_queue) replicator = self.m_tcp_replicator()
self.assertTrue(replicator.is_alive()) self.assertTrue(replicator.is_alive())
replicator._connected_clients.append(m_client) replicator._connected_clients.append(m_client)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment