예제 #1
0
def test_index_controller_index_action_with_created_projects():
    global store
    clear()
    proj = Project(
        name=u"Index Test Project 2",
        build_script=u"test build script",
        scm_repository=u"scm_repository",
        monitor_changes=False,
        branch="master",
    )

    store.add(proj)

    store.commit()

    server = Server(root_dir)

    server.start("tests/functional/config.ini", non_block=True)

    while not server.status == ServerStatus.Started:
        time.sleep(0.5)

    controller = IndexController()
    controller.server = server

    content = controller.index()

    assert content
예제 #2
0
def test_server_can_start():
    clear()
    server = Server(root_dir=root_dir)
    try:
        server.start(config_path=config_path, non_block=True)

        assert server.status == ServerStatus.Started
    finally:
        server.stop()
예제 #3
0
def run_skink_server():
    root_dir = abspath(dirname(__file__))
    server = Server(root_dir=root_dir)
    server.build_dir = join(root_dir, "ci_tmp")

    server.subscribe('on_user_authentication_failed', on_user_authentication_failed_handler)

    server.context.current_project = None
    server.context.current_command = None
    server.context.current_log = ""
    server.context.build_queue = Queue.deque()
    server.context.projects_being_built = Queue.deque()

    builder = BuilderPlugin(cherrypy.engine, server)
    builder.subscribe()

    monitor = MonitorPlugin(cherrypy.engine, server)
    monitor.subscribe()

    try:
        server.start("config.ini", non_block=True)
        for plugin in SkinkPlugin.all():
            config = server.context.settings.config
            if config.has_section(plugin.__name__) and \
               config.get(plugin.__name__, "enabled") == "True":
                cherrypy.log('Plugin %s enabled!' % plugin.__name__,
                             'PLUGINS')
                instance = plugin(server)

        cherrypy.engine.block()
    except KeyboardInterrupt:
        server.stop()
예제 #4
0
class ServerHelper (object):

    def __init__(self, root_path, config_path):
        self.server = Server(root_path)

        self.server.start(config_path, non_block=True)

        while not self.server.status == ServerStatus.Started:
            time.sleep(0.5)

    def ctrl(self, controller):
        _ctrl = controller()
        _ctrl.server = self.server
        return _ctrl
예제 #5
0
    def __init__(self, root_path, config_path):
        self.server = Server(root_path)

        self.server.start(config_path, non_block=True)

        while not self.server.status == ServerStatus.Started:
            time.sleep(0.5)
예제 #6
0
def test_project_controller_new_action():
    global store
    clear()
    server = Server(root_dir)

    server.start("tests/functional/config.ini", non_block=True)

    while not server.status == ServerStatus.Started:
        time.sleep(0.5)

    controller = ProjectController()
    controller.server = server

    content = controller.new()

    assert content
예제 #7
0
def test_server_responds_for_healthcheck_action():
    clear()

    class TestController(Controller):
        pass

    server = Server(root_dir=root_dir)

    try:
        server.start(config_path=config_path, non_block=True)

        status_code, content = HttpClient.get(join(server.context.settings.Ion.baseurl, "healthcheck"))

        assert status_code == 200
        assert content == "WORKING"
    finally:
        server.stop()
예제 #8
0
def test_project_controller_create_action_assigns_true_to_monitor_changes_if_string_MONITOR():
    global store
    clear()
    server = Server(root_dir)

    server.start("tests/functional/config.ini", non_block=True)

    while not server.status == ServerStatus.Started:
        time.sleep(0.5)

    controller = ProjectController()
    controller.server = server

    try:
        controller.create(u"name", u"build_script", u"scm_repository", u"MONITOR")
    except cherrypy.HTTPRedirect:
        return

    assert False, "Shouldn't have reached this far."
예제 #9
0
def test_server_responds_for_controller_action():
    clear()

    class TestController(Controller):
        @route("/")
        def SomeAction(self):
            return "Hello World"

    server = Server(root_dir=root_dir)

    try:
        server.start(config_path=config_path, non_block=True)

        status_code, content = HttpClient.get(server.context.settings.Ion.baseurl)

        assert status_code == 200
        assert content == "Hello World"
    finally:
        server.stop()