def setup(self):
        """
        User being used during test: id = 5, username = test1
        """
        self.port = 8084
        handle_db_seed()
        self.app = APP
        self.app.config['SQLALCHEMY_DATABASE_URI'] = mscolab_settings.SQLALCHEMY_DB_URI
        self.app.config['MSCOLAB_DATA_DIR'] = mscolab_settings.MSCOLAB_DATA_DIR
        self.app, sockio, cm, fm = initialize_managers(self.app)
        self.fm = fm
        self.cm = cm
        db.init_app(self.app)
        self.MSCOLAB_URL_TEST = f"http://localhost:{self.port}"

        self.application = QtWidgets.QApplication(sys.argv)
        self.window = MSSMscolabWindow(data_dir=mscolab_settings.MSCOLAB_DATA_DIR,
                                       mscolab_server_url=self.MSCOLAB_URL_TEST)
        self._login()
        self._activate_project_at_index(0)
        QtTest.QTest.mouseClick(self.window.adminWindowBtn, QtCore.Qt.LeftButton)
        QtWidgets.QApplication.processEvents()
        self.admin_window = self.window.admin_window
        QtTest.QTest.qWaitForWindowExposed(self.window)
        QtWidgets.QApplication.processEvents()
Exemple #2
0
def mscolab_start_server(all_ports, mscolab_settings=mscolab_settings):
    handle_db_seed()
    port = mscolab_check_free_port(all_ports, all_ports.pop())

    url = f"http://localhost:{port}"

    _app = APP
    _app.config['SQLALCHEMY_DATABASE_URI'] = mscolab_settings.SQLALCHEMY_DB_URI
    _app.config['MSCOLAB_DATA_DIR'] = mscolab_settings.MSCOLAB_DATA_DIR
    _app.config['UPLOAD_FOLDER'] = mscolab_settings.UPLOAD_FOLDER
    _app.config['URL'] = url

    _app, sockio, cm, fm = initialize_managers(_app)

    # ToDo refactoring for spawn needed, fork is not implemented on windows, spawn is default on MAC and Windows
    if multiprocessing.get_start_method(allow_none=True) != 'fork':
        multiprocessing.set_start_method("fork")
    process = multiprocessing.Process(target=start_server,
                                      args=(
                                          _app,
                                          sockio,
                                          cm,
                                          fm,
                                      ),
                                      kwargs={'port': port})
    process.start()
    return process, url, _app, sockio, cm, fm
Exemple #3
0
 def setup(self):
     handle_db_seed()
     self.app = APP
     self.app.config[
         'SQLALCHEMY_DATABASE_URI'] = mscolab_settings.SQLALCHEMY_DB_URI
     self.app.config['MSCOLAB_DATA_DIR'] = mscolab_settings.MSCOLAB_DATA_DIR
     self.app, _, cm, _ = initialize_managers(self.app)
     self.cm = cm
     db.init_app(self.app)
Exemple #4
0
 def test_handle_db_seed(self):
     handle_db_reset()
     all_operations = Operation.query.all()
     assert all_operations == []
     handle_db_seed()
     all_operations = Operation.query.all()
     assert len(all_operations) == 6
     assert all_operations[0].path == "one"
     all_users = User.query.all()
     assert len(all_users) == 10
     all_permissions = Permission.query.all()
     assert len(all_permissions) == 17
Exemple #5
0
 def setup(self):
     handle_db_seed()
     self.app = APP
     self.app.config[
         'SQLALCHEMY_DATABASE_URI'] = mscolab_settings.SQLALCHEMY_DB_URI
     self.app.config['MSCOLAB_DATA_DIR'] = mscolab_settings.MSCOLAB_DATA_DIR
     self.app.config['UPLOAD_FOLDER'] = mscolab_settings.UPLOAD_FOLDER
     self.app, _, cm, fm = initialize_managers(self.app)
     self.fm = fm
     self.cm = cm
     db.init_app(self.app)
     with self.app.app_context():
         self.user = User.query.filter_by(id=8).first()
Exemple #6
0
 def setup(self):
     assert 'tmp' in mscolab_settings.MSCOLAB_DATA_DIR
     handle_db_seed()
     self.sockets = []
     self.app = APP
     self.app.config[
         'SQLALCHEMY_DATABASE_URI'] = mscolab_settings.SQLALCHEMY_DB_URI
     self.app.config['MSCOLAB_DATA_DIR'] = mscolab_settings.MSCOLAB_DATA_DIR
     db.init_app(self.app)
     self.fm = file_manager.FileManager(mscolab_settings.MSCOLAB_DATA_DIR)
     self._example_data()
     self.cleanup_pid = set()
     data = {'email': 'a', 'password': '******'}
     r = requests.post(MSCOLAB_URL_TEST + '/token', data=data)
     self.token = json.loads(r.text)['token']
     with self.app.app_context():
         self.user = User.query.filter_by(id=8).first()
Exemple #7
0
 def setup(self):
     handle_db_seed()
     self.port = 8084
     self.app = APP
     self.app.config[
         'SQLALCHEMY_DATABASE_URI'] = mscolab_settings.SQLALCHEMY_DB_URI
     self.app.config['MSCOLAB_DATA_DIR'] = mscolab_settings.MSCOLAB_DATA_DIR
     self.app.config['UPLOAD_FOLDER'] = mscolab_settings.UPLOAD_FOLDER
     self.app, sockio, cm, fm = initialize_managers(self.app)
     self.fm = fm
     self.cm = cm
     db.init_app(self.app)
     self.MSCOLAB_URL_TEST = f"http://localhost:{self.port}"
     logging.debug("starting")
     self.application = QtWidgets.QApplication(sys.argv)
     self.window = MSSMscolabWindow(
         data_dir=mscolab_settings.MSCOLAB_DATA_DIR,
         mscolab_server_url=self.MSCOLAB_URL_TEST)
    def setup(self):
        handle_db_seed()
        self.application = QtWidgets.QApplication(sys.argv)
        self.window = MSSMscolabWindow(data_dir=mscolab_settings.MSCOLAB_DATA_DIR,
                                       mscolab_server_url=MSCOLAB_URL_TEST)
        self.window.show()
        QtWidgets.QApplication.processEvents()
        QtTest.QTest.qWaitForWindowExposed(self.window)
        QtWidgets.QApplication.processEvents()

        self.app = APP
        self.app.config['SQLALCHEMY_DATABASE_URI'] = mscolab_settings.SQLALCHEMY_DB_URI
        self.app.config['MSCOLAB_DATA_DIR'] = mscolab_settings.MSCOLAB_DATA_DIR
        self.app.config['UPLOAD_FOLDER'] = mscolab_settings.UPLOAD_FOLDER
        self.app, _, cm, fm = initialize_managers(self.app)
        self.fm = fm
        self.cm = cm
        db.init_app(self.app)
Exemple #9
0
def create_data():
    from mslib.mscolab.mscolab import handle_db_seed
    handle_db_seed()
    yield
    constants.ROOT_FS.clean()