示例#1
0
 def test_perform_add(self):
     data = "ADD 1 2 x".split()
     assert tcp_server.TREE == tcp_server.CustomIntervalTree()
     self.thread.perform_add(data)
     assert tcp_server.TREE == tcp_server.CustomIntervalTree(
         [Interval(1, 2, "x")])
     self.thread.conn.send.assert_called_with(str.encode("OK\n"))
示例#2
0
 def test_perform_delete_partial_entry(self):
     data = "ADD 1 5 x".split()
     assert tcp_server.TREE == tcp_server.CustomIntervalTree()
     self.thread.perform_add(data)
     assert tcp_server.TREE == tcp_server.CustomIntervalTree(
         [Interval(1, 5, "x")])
     self.thread.conn.send.assert_called_with(str.encode("OK\n"))
     data = "DEL 2 3 x".split()
     self.thread.perform_delete(data)
     assert tcp_server.TREE == tcp_server.CustomIntervalTree(
         [Interval(1, 2, "x"), Interval(4, 5, "x")])
     self.thread.conn.send.assert_called_with(str.encode("OK\n"))
示例#3
0
 def test_perform_find_specific_range(self):
     data = "ADD 1 5 x".split()
     assert tcp_server.TREE == tcp_server.CustomIntervalTree()
     self.thread.perform_add(data)
     assert tcp_server.TREE == tcp_server.CustomIntervalTree(
         [Interval(1, 5, "x")])
     self.thread.conn.send.assert_called_with(str.encode("OK\n"))
     data = "ADD 5 10 y".split()
     self.thread.perform_add(data)
     assert tcp_server.TREE == tcp_server.CustomIntervalTree(
         [Interval(1, 5, "x"), Interval(5, 10, "y")])
     self.thread.conn.send.assert_called_with(str.encode("OK\n"))
     data = "FIND 2 7".split()
     self.thread.perform_find(data)
     self.thread.conn.send.assert_called_with(str.encode("x y\n"))
示例#4
0
 def test_perform_find_no_results(self):
     data = "FIND 1".split()
     assert tcp_server.TREE == tcp_server.CustomIntervalTree()
     self.thread.perform_find(data)
     self.thread.conn.send.assert_called_with(
         str.encode("ERROR no results\n"))
示例#5
0
 def tearDown(self):
     tcp_server.TREE = tcp_server.CustomIntervalTree()
     """Tear down test fixtures, if any."""
示例#6
0
 def setUp(self):
     tcp_server.TREE = tcp_server.CustomIntervalTree()
     mock.patch("tcp_server.socket.socket")
     self.thread = tcp_server.ClientThread(mock.Mock(), "localhost", 2004)
     """Set up test fixtures, if any."""