Exemplo n.º 1
0
def run_process(process):
    # Call the process with a little trick to ignore the keyboard interrupt error when it happens
    try:
        if 'test' in process:
            set_testing_environment(True)
        return subprocess.call(process)
    except KeyboardInterrupt:
        pass
    finally:
        set_testing_environment(False)
Exemplo n.º 2
0
def run_process(process):
    # Call the process with a little trick to ignore the keyboard interrupt error when it happens
    try:
        if 'test' in process:
            set_testing_environment(True)
        return subprocess.call(process)
    except KeyboardInterrupt:
        pass
    finally:
        set_testing_environment(False)
Exemplo n.º 3
0
    def test_set_testing_environment(self):
        base_environment.set_testing_environment(True)
        self.assertEqual('true', environ['TETHYS_TESTING_IN_PROGRESS'])

        result = base_environment.is_testing_environment()
        self.assertEqual('true', result)

        base_environment.set_testing_environment(False)
        self.assertIsNone(environ.get('TETHYS_TESTING_IN_PROGRESS'))

        result = base_environment.is_testing_environment()
        self.assertIsNone(result)
Exemplo n.º 4
0
    def create_test_persistent_stores_for_app(app_class):
        """
        Creates temporary persistent store databases for this app to be used in testing.

        Args:
            app_class: The app class from the app's app.py module
        Return:
            None
        """
        set_testing_environment(True)

        if not issubclass(app_class, TethysAppBase):
            raise TypeError(
                'The app_class argument was not of the correct type. '
                'It must be a class that inherits from <TethysAppBase>.')

        for store in app_class().list_persistent_store_databases(
                static_only=True):
            if app_class.persistent_store_exists(store.name):
                app_class.drop_persistent_store(store.name)

            create_store_success = app_class.create_persistent_store(
                store.name, spatial=store.spatial)

            error = False
            if create_store_success:
                retry_counter = 0
                while True:
                    if retry_counter < 5:
                        try:
                            store.initializer_function(True)
                            break
                        except Exception as e:
                            if 'terminating connection due to administrator command' in str(
                                    e):
                                pass
                            else:
                                error = True
                    else:
                        error = True
                        break
            else:
                error = True

            if error:
                raise SystemError('The test store was not able to be created')
Exemplo n.º 5
0
    def destroy_test_persistent_stores_for_app(app_class):
        """
        Destroys the temporary persistent store databases for this app that were used in testing.

        Args:
            app_class: The app class from the app's app.py module
        Return:
            None
        """
        set_testing_environment(True)

        if not issubclass(app_class, TethysAppBase):
            raise TypeError('The app_class argument was not of the correct type. '
                            'It must be a class that inherits from <TethysAppBase>.')

        for store in app_class().list_persistent_store_databases(static_only=True):
            test_store_name = 'tethys-testing_{0}'.format(store.name)
            app_class.drop_persistent_store(test_store_name)
Exemplo n.º 6
0
    def create_test_persistent_stores_for_app(app_class):
        """
        Creates temporary persistent store databases for this app to be used in testing.

        Args:
            app_class: The app class from the app's app.py module
        Return:
            None
        """
        set_testing_environment(True)

        if not issubclass(app_class, TethysAppBase):
            raise TypeError('The app_class argument was not of the correct type. '
                            'It must be a class that inherits from <TethysAppBase>.')

        for store in app_class().list_persistent_store_databases(static_only=True):
            if app_class.persistent_store_exists(store.name):
                app_class.drop_persistent_store(store.name)

            create_store_success = app_class.create_persistent_store(store.name, spatial=store.spatial)

            error = False
            if create_store_success:
                retry_counter = 0
                while True:
                    if retry_counter < 5:
                        try:
                            store.initializer_function(True)
                            break
                        except Exception as e:
                            if 'terminating connection due to administrator command' in str(e):
                                pass
                            else:
                                error = True
                    else:
                        error = True
                        break
            else:
                error = True

            if error:
                raise SystemError('The test store was not able to be created')
Exemplo n.º 7
0
    def destroy_test_persistent_stores_for_app(app_class):
        """
        Destroys the temporary persistent store databases for this app that were used in testing.

        Args:
            app_class: The app class from the app's app.py module
        Return:
            None
        """
        set_testing_environment(True)

        if not issubclass(app_class, TethysAppBase):
            raise TypeError(
                'The app_class argument was not of the correct type. '
                'It must be a class that inherits from <TethysAppBase>.')

        for store in app_class().list_persistent_store_databases(
                static_only=True):
            test_store_name = 'tethys-testing_{0}'.format(store.name)
            app_class.drop_persistent_store(test_store_name)
Exemplo n.º 8
0
 def tearDown(self):
     set_testing_environment(True)
Exemplo n.º 9
0
 def setUp(self):
     set_testing_environment(False)
Exemplo n.º 10
0
 def tearDown(self):
     set_testing_environment(True)
Exemplo n.º 11
0
 def setUp(self):
     set_testing_environment(False)