def test_stepExecutionEvents(self):
        workflow_name = construct_workflow_name_key('basicWorkflowTest', 'helloWorldWorkflow')
        c = controller.Controller(name="testStepExecutionEventsController")
        c.load_workflows_from_file(path=config.test_workflows_path + "basicWorkflowTest.workflow")

        subs = {'testStepExecutionEventsController':
            Subscription(subscriptions=
            {workflow_name:
                Subscription(subscriptions=
                {'start':
                    Subscription(
                        events=["Function Execution Success", "Input Validated",
                                "Conditionals Executed"])})})}

        case_subscription.set_subscriptions(
            {'testStepExecutionEvents': case_subscription.CaseSubscriptions(subscriptions=subs)})

        c.execute_workflow('basicWorkflowTest', 'helloWorldWorkflow')

        running_context.shutdown_threads()

        step_execution_events_case = case_database.case_db.session.query(case_database.Case) \
            .filter(case_database.Case.name == 'testStepExecutionEvents').first()
        step_execution_event_history = step_execution_events_case.events.all()
        self.assertEqual(len(step_execution_event_history), 3,
                         'Incorrect length of event history. '
                         'Expected {0}, got {1}'.format(3, len(step_execution_event_history)))
Exemple #2
0
def run_game():
    """ Initial function to run the game """

    # Initialize pygame
    pygame.init()

    # Setup settings
    pong_settings = settings.Settings()
    main_screen = pygame.display.set_mode(
        (pong_settings.WINDOW_WIDTH, pong_settings.WINDOW_HEIGHT))
    pygame.display.set_caption("Pong by Randy Le 2019")

    # Initialize a game mode
    pong_gamemode = gamemode.Gamemode()

    # Initialize a player controller
    player_controller = controller.Controller()

    # Initialize screen manager
    screen_manager = screenmanager.ScreenManager(main_screen, pong_settings,
                                                 pong_gamemode,
                                                 player_controller)

    while True:
        """ Game loop, as long as this is true the game will still run."""
        main_screen.fill(pong_settings.BACKGROUND_COLOR)
        screen_manager.run()

        # Display the screen onto the window
        pygame.display.flip()
        pong_settings.main_clock.tick(30)
Exemple #3
0
 def setUp(self):
     self.c = controller.Controller()
     self.c.load_playbook(resource=config.test_workflows_path +
                          'basicWorkflowTest.playbook')
     self.testWorkflow = self.c.get_workflow('basicWorkflowTest',
                                             'helloWorldWorkflow')
     self.workflow_uid = "c5a7c29a0f844b69a59901bb542e9305"
    def test_workflowExecutionEvents(self):
        c = controller.Controller(name="testExecutionEventsController")
        c.loadWorkflowsFromFile(path=config.testWorkflowsPath +
                                "multiactionWorkflowTest.workflow")

        subs = {
            'testExecutionEventsController':
            Subscription(
                subscriptions={
                    'multiactionWorkflow':
                    Subscription(events=[
                        "InstanceCreated", "StepExecutionSuccess",
                        "NextStepFound", "WorkflowShutdown"
                    ])
                })
        }

        case_subscription.set_subscriptions({
            'testExecutionEvents':
            case_subscription.CaseSubscriptions(subscriptions=subs)
        })

        c.executeWorkflow(name="multiactionWorkflow")

        execution_events_case = case_database.case_db.session.query(case_database.Cases) \
            .filter(case_database.Cases.name == 'testExecutionEvents').first()
        execution_event_history = execution_events_case.events.all()
        self.assertEqual(
            len(execution_event_history), 6,
            'Incorrect length of event history. '
            'Expected {0}, got {1}'.format(6, len(execution_event_history)))
Exemple #5
0
    def test_ffkExecutionEvents(self):
        workflow_name = construct_workflow_name_key('basicWorkflowTest', 'helloWorldWorkflow')
        c = controller.Controller(name="testStepFFKEventsController")
        c.loadWorkflowsFromFile(path=config.testWorkflowsPath + "basicWorkflowTest.workflow")

        filter_sub = Subscription(events=['FilterSuccess', 'FilterError'])
        flag_sub = Subscription(events=['FlagArgsValid', 'FlagArgsInvalid'], subscriptions={'length': filter_sub})
        next_sub = Subscription(events=['NextStepTaken', 'NextStepNotTaken'], subscriptions={'regMatch': flag_sub})
        step_sub = Subscription(events=["FunctionExecutionSuccess", "InputValidated", "ConditionalsExecuted"],
                                subscriptions={'1': next_sub})
        subs = {'testStepFFKEventsController':
                    Subscription(subscriptions=
                                 {workflow_name:
                                      Subscription(subscriptions=
                                                   {'start': step_sub})})}

        case_subscription.set_subscriptions(
            {'testStepFFKEventsEvents': case_subscription.CaseSubscriptions(subscriptions=subs)})

        c.executeWorkflow('basicWorkflowTest', 'helloWorldWorkflow')

        step_ffk_events_case = case_database.case_db.session.query(case_database.Case) \
            .filter(case_database.Case.name == 'testStepFFKEventsEvents').first()
        step_ffk_event_history = step_ffk_events_case.events.all()
        self.assertEqual(len(step_ffk_event_history), 6,
                         'Incorrect length of event history. '
                         'Expected {0}, got {1}'.format(6, len(step_ffk_event_history)))
 def setUp(self):
     self.c = controller.Controller()
     self.c.load_workflows_from_file(path=config.test_workflows_path +
                                     'basicWorkflowTest.playbook')
     self.workflow_name = _WorkflowKey('basicWorkflowTest',
                                       'helloWorldWorkflow')
     self.testWorkflow = self.c.workflows[self.workflow_name]
    def test_pauseResumeSchedulerExecution(self):
        c = controller.Controller(name="pauseResumeController")
        c.load_workflows_from_file(path=config.test_workflows_path + "testScheduler.workflow")

        subs = {'pauseResumeController': Subscription(events=[EVENT_SCHEDULER_START, EVENT_SCHEDULER_SHUTDOWN,
                                                              EVENT_SCHEDULER_PAUSED, EVENT_SCHEDULER_RESUMED,
                                                              EVENT_JOB_ADDED, EVENT_JOB_REMOVED,
                                                              EVENT_JOB_EXECUTED, EVENT_JOB_ERROR])}
        case_subscription.set_subscriptions({'startStop': case_subscription.CaseSubscriptions(subscriptions=subs)})
        case_subscription.set_subscriptions({'pauseResume': case_subscription.CaseSubscriptions(subscriptions=subs)})

        c.start()
        c.pause()
        time.sleep(1)
        c.resume()
        time.sleep(1)
        c.stop(wait=False)

        pause_resume_events_case = case_database.case_db.session.query(case_database.Case) \
            .filter(case_database.Case.name == 'pauseResume').first()
        pause_resume_event_history = pause_resume_events_case.events.all()

        self.assertEqual(len(pause_resume_event_history), 4,
                        'Incorrect length of event history. '
                        'Expected {0}, got {1}'.format(4, len(pause_resume_event_history)))
 def setUp(self):
     self.c = controller.Controller()
     self.c.loadWorkflowsFromFile(path=config.testWorkflowsPath +
                                  'basicWorkflowTest.workflow')
     self.workflow_name = _WorkflowKey('basicWorkflowTest',
                                       'helloWorldWorkflow')
     self.testWorkflow = self.c.workflows[self.workflow_name]
 def setUp(self):
     self.c = controller.Controller()
     self.c.loadWorkflowsFromFile(path=config.testWorkflowsPath +
                                  "basicWorkflowTest.workflow")
     self.c.loadWorkflowsFromFile(path=config.testWorkflowsPath +
                                  "multiactionWorkflowTest.workflow")
     self.c.loadWorkflowsFromFile(path=config.testWorkflowsPath +
                                  "templatedWorkflowTest.workflow")
     self.c.loadWorkflowsFromFile(path=config.testWorkflowsPath +
                                  "multistepError.workflow")
Exemple #10
0
    def __init__(self):
        self.term = Terminal()
        self.scriptPath = os.path.dirname(os.path.realpath(__file__))
        self.banner()
        self.arguments = arghandle.ArgHandle()
        hostList = self.arguments.getHostList()
        par = self.arguments.getParDic()

        if hostList != None and len(hostList) > 0:
            contro = controller.Controller(self.term, self.scriptPath,
                                           hostList, par)
            contro.working()
        else:
            print "Parameter format is not correct !\nPlease look for help e.g. -h"
 def setUp(self):
     case_database.initialize()
     self.app = flask_server.app.test_client(self)
     self.app.testing = True
     self.app.post('/login',
                   data=dict(email='admin', password='******'),
                   follow_redirects=True)
     self.c = controller.Controller()
     self.c.loadWorkflowsFromFile(
         path=path.join(config.testWorkflowsPath,
                        'simpleDataManipulationWorkflow.workflow'))
     self.id_tuple = ('simpleDataManipulationWorkflow',
                      'helloWorldWorkflow')
     self.workflow_name = construct_workflow_name_key(*self.id_tuple)
     self.testWorkflow = self.c.get_workflow(*self.id_tuple)
 def setUp(self):
     case_database.initialize()
     self.app = server.app.test_client(self)
     self.app.testing = True
     self.app.post('/login',
                   data=dict(email='admin', password='******'),
                   follow_redirects=True)
     self.c = controller.Controller()
     self.c.loadWorkflowsFromFile(path=config.testWorkflowsPath +
                                  "basicWorkflowTest.workflow")
     self.c.loadWorkflowsFromFile(path=config.testWorkflowsPath +
                                  "multiactionWorkflowTest.workflow")
     self.c.loadWorkflowsFromFile(path=config.testWorkflowsPath +
                                  "multistepError.workflow")
     self.start = datetime.utcnow()
Exemple #13
0
    def test_start_stop_execution_loop(self):
        c = controller.Controller()
        c.load_playbook(resource=config.test_workflows_path + "testScheduler.playbook")
        subs = {'controller': [EVENT_SCHEDULER_START, EVENT_SCHEDULER_SHUTDOWN, EVENT_SCHEDULER_PAUSED,
                               EVENT_SCHEDULER_RESUMED, EVENT_JOB_ADDED, EVENT_JOB_REMOVED, EVENT_JOB_EXECUTED,
                               EVENT_JOB_ERROR]}
        case_subscription.set_subscriptions({'case1': subs})
        c.scheduler.start()
        time.sleep(0.1)
        c.scheduler.stop(wait=False)

        start_stop_event_history = case_database.case_db.session.query(case_database.Case) \
            .filter(case_database.Case.name == 'case1').first().events.all()
        self.assertEqual(len(start_stop_event_history), 2,
                         'Incorrect length of event history. '
                         'Expected {0}, got {1}'.format(2, len(start_stop_event_history)))
Exemple #14
0
    def test_startStopExecutionLoop(self):
        c = controller.Controller(name="startStopController")
        c.loadWorkflowsFromFile(path=config.testWorkflowsPath + "testScheduler.workflow")
        subs = {'startStopController': Subscription(events=[EVENT_SCHEDULER_START, EVENT_SCHEDULER_SHUTDOWN,
                                                            EVENT_SCHEDULER_PAUSED, EVENT_SCHEDULER_RESUMED,
                                                            EVENT_JOB_ADDED, EVENT_JOB_REMOVED,
                                                            EVENT_JOB_EXECUTED, EVENT_JOB_ERROR])}
        case_subscription.set_subscriptions({'startStop': case_subscription.CaseSubscriptions(subscriptions=subs)})
        c.start()
        time.sleep(1)
        c.stop(wait=False)

        start_stop_event_history = case_database.case_db.session.query(case_database.Cases) \
            .filter(case_database.Cases.name == 'startStop').first().events.all()
        self.assertEqual(len(start_stop_event_history), 2,
                         'Incorrect length of event history. '
                         'Expected {0}, got {1}'.format(2, len(start_stop_event_history)))
    def test_ffkExecutionEventsCase(self):
        c = controller.Controller(name="testStepFFKEventsController")
        c.load_workflows_from_file(path=config.test_workflows_path + "basicWorkflowTest.workflow")
        workflow_name = construct_workflow_name_key('basicWorkflowTest', 'helloWorldWorkflow')
        filter_sub = Subscription(events=['Filter Error'])
        flag_sub = Subscription(events=['Flag Arguments Valid',
                                        'Flag Arguments Invalid'], subscriptions={'length': filter_sub})
        next_sub = Subscription(events=['Next Step Taken',
                                        'Next Step Not Taken'],
                                subscriptions={'regMatch': flag_sub})
        step_sub = Subscription(events=['Function Execution Success',
                                        'Input Validated',
                                        'Conditionals Executed'], subscriptions={'1': next_sub})
        subs = {'testStepFFKEventsController':
                    Subscription(subscriptions=
                                 {workflow_name:
                                      Subscription(subscriptions=
                                                   {'start': step_sub})})}
        global_subs = case_subscription.GlobalSubscriptions(step=['Function Execution Success',
                                                                  'Input Validated',
                                                                  'Conditionals Executed'],
                                                            next_step=['Next Step Taken',
                                                                       'Next Step Not Taken'],
                                                            flag=['Flag Arguments Valid',
                                                                  'Flag Arguments Invalid'],
                                                            filter=['Filter Error'])
        case_subscription.set_subscriptions(
            {'testStepFFKEventsEvents': case_subscription.CaseSubscriptions(subscriptions=subs,
                                                                            global_subscriptions=global_subs)})

        c.execute_workflow('basicWorkflowTest', 'helloWorldWorkflow')

        running_context.shutdown_threads()

        step_ffk_events_case = case_database.case_db.session.query(case_database.Case) \
            .filter(case_database.Case.name == 'testStepFFKEventsEvents').first()
        step_ffk_event_history = step_ffk_events_case.events.all()
        self.assertEqual(len(step_ffk_event_history), 5,
                         'Incorrect length of event history. '
                         'Expected {0}, got {1}'.format(5, len(step_ffk_event_history)))
        step_json = [step.as_json() for step in step_ffk_event_history if step.as_json()['message'] == 'STEP']
        for step in step_json:
            if step['type'] == 'Function executed successfully':
                self.assertDictEqual(step['data'], {'result': 'REPEATING: Hello World'})
            else:
                self.assertEqual(step['data'], '')
    def test_stepExecutionEvents(self):
        c = controller.Controller(name="testStepExecutionEventsController")
        c.loadWorkflowsFromFile(path=config.testWorkflowsPath +
                                "basicWorkflowTest.workflow")

        subs = {
            'testStepExecutionEventsController':
            Subscription(
                subscriptions={
                    'helloWorldWorkflow':
                    Subscription(
                        subscriptions={
                            'start':
                            Subscription(events=[
                                "FunctionExecutionSuccess", "InputValidated",
                                "ConditionalsExecuted"
                            ])
                        })
                })
        }

        case_subscription.set_subscriptions({
            'testStepExecutionEvents':
            case_subscription.CaseSubscriptions(subscriptions=subs)
        })

        c.executeWorkflow(name="helloWorldWorkflow")

        step_execution_events_case = case_database.case_db.session.query(case_database.Cases) \
            .filter(case_database.Cases.name == 'testStepExecutionEvents').first()
        step_execution_event_history = step_execution_events_case.events.all()
        self.assertEqual(
            len(step_execution_event_history), 3,
            'Incorrect length of event history. '
            'Expected {0}, got {1}'.format(3,
                                           len(step_execution_event_history)))
    def test_workflowExecutionEvents(self):
        workflow_name = construct_workflow_name_key('multiactionWorkflowTest', 'multiactionWorkflow')
        c = controller.Controller(name="testExecutionEventsController")
        c.load_workflows_from_file(path=config.test_workflows_path + "multiactionWorkflowTest.workflow")

        subs = {'testExecutionEventsController':
                    Subscription(subscriptions=
                                 {workflow_name:
                                      Subscription(events=["App Instance Created", "Step Execution Success",
                                                           "Next Step Found", "Workflow Shutdown"])})}

        case_subscription.set_subscriptions(
            {'testExecutionEvents': case_subscription.CaseSubscriptions(subscriptions=subs)})

        c.execute_workflow('multiactionWorkflowTest', 'multiactionWorkflow')

        running_context.shutdown_threads()

        execution_events_case = case_database.case_db.session.query(case_database.Case) \
            .filter(case_database.Case.name == 'testExecutionEvents').first()
        execution_event_history = execution_events_case.events.all()
        self.assertEqual(len(execution_event_history), 6,
                         'Incorrect length of event history. '
                         'Expected {0}, got {1}'.format(6, len(execution_event_history)))
    def test_ffkExecutionEventsCase(self):
        c = controller.Controller(name="testStepFFKEventsController")
        c.loadWorkflowsFromFile(path=config.testWorkflowsPath +
                                "basicWorkflowTest.workflow")
        filter_sub = Subscription(disabled=['FilterSuccess'])
        flag_sub = Subscription(subscriptions={'length': filter_sub})
        next_sub = Subscription(subscriptions={'regMatch': flag_sub})
        step_sub = Subscription(subscriptions={'1': next_sub})
        subs = {
            'testStepFFKEventsController':
            Subscription(
                subscriptions={
                    'helloWorldWorkflow':
                    Subscription(subscriptions={'start': step_sub})
                })
        }
        global_subs = case_subscription.GlobalSubscriptions(
            step='*',
            next_step=['NextStepTaken', 'NextStepNotTaken'],
            flag=['FlagArgsValid', 'FlagArgsInvalid'],
            filter=['FilterSuccess', 'FilterError'])
        case_subscription.set_subscriptions({
            'testStepFFKEventsEvents':
            case_subscription.CaseSubscriptions(
                subscriptions=subs, global_subscriptions=global_subs)
        })

        c.executeWorkflow(name="helloWorldWorkflow")

        step_ffk_events_case = case_database.case_db.session.query(case_database.Cases) \
            .filter(case_database.Cases.name == 'testStepFFKEventsEvents').first()
        step_ffk_event_history = step_ffk_events_case.events.all()
        self.assertEqual(
            len(step_ffk_event_history), 5,
            'Incorrect length of event history. '
            'Expected {0}, got {1}'.format(5, len(step_ffk_event_history)))
Exemple #19
0
 def setUp(self):
     self.c = controller.Controller()
     self.c.loadWorkflowsFromFile(path=config.testWorkflowsPath +
                                  "basicWorkflowTest.workflow")
     self.testWorkflow = self.c.workflows["helloWorldWorkflow"]
Exemple #20
0
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import os, locale, sys
from core import controller

locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8')

debug = False
if len(sys.argv) > 1: debug = sys.argv[1] == '-d'
# Initialisation du controller principale
ctrl = controller.Controller(debug)
# démarrage du serveur
ctrl.run()
Exemple #21
0
 def setUp(self):
     self.c = controller.Controller()
     self.c.load_playbook(resource=config.test_workflows_path + 'basicWorkflowTest.playbook')
     self.testWorkflow = self.c.get_workflow('basicWorkflowTest', 'helloWorldWorkflow')
Exemple #22
0
        adminRole = user_datastore.create_role(name="admin",
                                               description="administrator",
                                               pages=default_urls)
        # userRole = user_datastore.create_role(name="user", description="user")

        u = user_datastore.create_user(email='admin',
                                       password=encrypt_password('admin'))
        # u2 = user_datastore.create_user(email='user', password=encrypt_password('user'))

        user_datastore.add_role_to_user(u, adminRole)

        database.db.session.commit()


# Temporary create controller
workflowManager = controller.Controller()
workflowManager.loadWorkflowsFromFile(
    path="tests/testWorkflows/basicWorkflowTest.workflow")
workflowManager.loadWorkflowsFromFile(
    path="tests/testWorkflows/multiactionWorkflowTest.workflow")

subs = {
    'defaultController':
    Subscription(
        subscriptions={
            'multiactionWorkflow':
            Subscription(events=[
                "InstanceCreated", "StepExecutionSuccess", "NextStepFound",
                "WorkflowShutdown"
            ])
        })
 def setUp(self):
     self.c = controller.Controller()
     if not isdir(core_config.profileVisualizationsPath):
         mkdir(core_config.profileVisualizationsPath)
 def setUp(self):
     case_database.initialize()
     self.c = controller.Controller()
     if not isdir(core_config.profileVisualizationsPath):
         mkdir(core_config.profileVisualizationsPath)
     self.start = datetime.utcnow()
 def setUp(self):
     self.c = controller.Controller()
     self.c.loadWorkflowsFromFile(path=config.testWorkflowsPath +
                                  "simpleDataManipulationWorkflow.workflow")
     self.testWorkflow = self.c.workflows["helloWorldWorkflow"]
Exemple #26
0
 def __init__(self):
     super(MainWindow, self).__init__()
     self.controller = controller.Controller()
     self.initUI()  #Initializes UI