# Path: vespa/controller.py
# class Controller(object):
#     def __init__(self, model, view, testmode=False):
#         self.model = model
#         self.view = view
#         self.testmode = testmode
# 
#     def handler(self, signum, false):
#         if signum == 2:
#             debug_init("Controller received shutting down")
#             self._shutdown()
# 
#     def _shutdown(self):
#         self.model.destroy()
# 
#         if not self.testmode:
#             exit(0)
# 
#         self.server.stop()
# 
#     def start(self):
#         debug5("Started Controller")
# 
#         if not self.testmode:
#             signal.signal(signal.SIGINT, self.handler)
# 
#         self.server = HttpServer("test server", "0.0.0.0", 8080,
#                                  server_handler, self)
#         self.server.start()


import pytest
import sys
import os
import socket
import SocketServer
import threading
import time
import requests
from vespa.controller import Controller

DOSSIER_COURANT = os.path.dirname(os.path.abspath(__file__))
DOSSIER_PARENT = os.path.dirname(DOSSIER_COURANT)
sys.path.append(DOSSIER_PARENT)


TEST_ARG1 = 'aloha:kikoo:lala'
TEST_STRING = 'hello|ola:alo|%s\\r%s' % (TEST_ARG1, TEST_ARG1)
HOST = '127.0.0.1'
PORT = 8080

class Model_light(object):
    def __init__(self):
        self.slaves = [("voname", "vo_host", 1234)]
        self.config = "configgoeshere"

    def sendRemote(self, dst, msg):
        if msg == "list_slaves|":
            fstr = repr(self.slaves)
        else:
            fstr = repr([ "%s :: %s" % (dst, msg) ])
        return fstr

    def destroy(self):
        pass

@pytest.fixture(scope='module')
def controller_instance():

# Path: vespa/controller.py
# class Controller(object):
#     def __init__(self, model, view, testmode=False):
#         self.model = model
#         self.view = view
#         self.testmode = testmode
# 
#     def handler(self, signum, false):
#         if signum == 2:
#             debug_init("Controller received shutting down")
#             self._shutdown()
# 
#     def _shutdown(self):
#         self.model.destroy()
# 
#         if not self.testmode:
#             exit(0)
# 
#         self.server.stop()
# 
#     def start(self):
#         debug5("Started Controller")
# 
#         if not self.testmode:
#             signal.signal(signal.SIGINT, self.handler)
# 
#         self.server = HttpServer("test server", "0.0.0.0", 8080,
#                                  server_handler, self)
#         self.server.start()


# Path: tests/test_controller.py
import pytest
import sys
import os
import socket
import SocketServer
import threading
import time
import requests
from vespa.controller import Controller


DOSSIER_COURANT = os.path.dirname(os.path.abspath(__file__))
DOSSIER_PARENT = os.path.dirname(DOSSIER_COURANT)
sys.path.append(DOSSIER_PARENT)


TEST_ARG1 = 'aloha:kikoo:lala'
TEST_STRING = 'hello|ola:alo|%s\\r%s' % (TEST_ARG1, TEST_ARG1)
HOST = '127.0.0.1'
PORT = 8080

class Model_light(object):
    def __init__(self):
        self.slaves = [("voname", "vo_host", 1234)]
        self.config = "configgoeshere"

    def sendRemote(self, dst, msg):
        if msg == "list_slaves|":
            fstr = repr(self.slaves)
        else:
            fstr = repr([ "%s :: %s" % (dst, msg) ])
        return fstr

    def destroy(self):
        pass

@pytest.fixture(scope='module')
def controller_instance():

    s = Controller(Model_light(), None, testmode=True)