# Path: vespa/node.py
# class Node(PThread):
#     # Overrides threading.Thread.run()
#     def run(self):
#         profiler = cProfile.Profile()
#         try:
#             return profiler.runcall(PThread.run, self)
#         finally:
#             profiler.dump_stats('myprofile-%s.profile' % (self.name))


import unittest
import pytest
import sys
import os
from vespa.node import Node
    node_instance.register_alert_handler(test_handler)
    assert test_handler in node_instance.alert_handlers

def test_get_backend(node_instance):
    with pytest.raises(AttributeError):
        node_instance.get_backend()

def test_find_node_empty(node_instance):
    assert node_instance.findNode("test_slave") == 'None'

def test_register(node_instance):
    node_instance.register("test_slave", "127.0.0.1", "31337")
    assert ("test_slave", "127.0.0.1", 31337) in node_instance.list_slaves()

def test_find_node(node_instance):
    node_instance.register("test_find", "127.0.0.1", "31333")
    assert (("test_slave", "127.0.0.1", 31337) == 
            node_instance.findNode("test_slave"))

def test_send_unknow(node_instance):
    assert node_instance.send("hello") == ["help#"]

def test_send_help(node_instance):
    assert (node_instance.send("help|") ==
            ['help#desc#destroy#findNode#get_backend#launch#list_slaves#'
            'listen_interface#register#register_alert_handler#sendAlert'
            '#sendRemote#sendRemotef#sendSocket#wait_backend#worker#'])


if __name__ == '__main__':

# Path: vespa/node.py
# class Node(PThread):
#     # Overrides threading.Thread.run()
#     def run(self):
#         profiler = cProfile.Profile()
#         try:
#             return profiler.runcall(PThread.run, self)
#         finally:
#             profiler.dump_stats('myprofile-%s.profile' % (self.name))


# Path: tests/test_node.py
import unittest
import pytest
import sys
import os
from vespa.node import Node

    node_instance.register_alert_handler(test_handler)
    assert test_handler in node_instance.alert_handlers

def test_get_backend(node_instance):
    with pytest.raises(AttributeError):
        node_instance.get_backend()

def test_find_node_empty(node_instance):
    assert node_instance.findNode("test_slave") == 'None'

def test_register(node_instance):
    node_instance.register("test_slave", "127.0.0.1", "31337")
    assert ("test_slave", "127.0.0.1", 31337) in node_instance.list_slaves()

def test_find_node(node_instance):
    node_instance.register("test_find", "127.0.0.1", "31333")
    assert (("test_slave", "127.0.0.1", 31337) == 
            node_instance.findNode("test_slave"))

def test_send_unknow(node_instance):
    assert node_instance.send("hello") == ["help#"]

def test_send_help(node_instance):
    assert (node_instance.send("help|") ==
            ['help#desc#destroy#findNode#get_backend#launch#list_slaves#'
            'listen_interface#register#register_alert_handler#sendAlert'
            '#sendRemote#sendRemotef#sendSocket#wait_backend#worker#'])


if __name__ == '__main__':

    unittest.main()