Beispiel #1
0
    def setUpClass(cls) -> None:
        ignore_aws_warning()

        DatabasePath.change_path(
            os.path.join(os.getcwd(), 'setup_window_test_db.sqlite3'))

        remove_db_file()
        return super().setUpClass()
Beispiel #2
0
    def setUpClass(cls) -> None:
        ignore_aws_warning()
        DatabasePath.change_path(os.path.join(os.getcwd(), 'setup_window_test_db.sqlite3'))

        remove_db_file()

        cls.pc = open_program()
        cls.pc.add_frame_to_paned_window(SetupWindow)
        update_program_controller_loop(cls.pc)

        cls.setup_window = cls.pc.select_frame(SetupWindow)

        return super().setUpClass()
Beispiel #3
0
    def setUpClass(cls) -> None:
        ignore_aws_warning()

        DatabasePath.change_path(
            os.path.join(os.getcwd(), 'update_database_test_db.sqlite3'))

        remove_db_file()

        cls.pc = open_program()
        cls.pc.add_frame_to_paned_window(UpdateDatabase)
        update_program_controller_loop(cls.pc)

        # MYPY ERROR: Incompatible types in assignment (expression has type "Union[MainWindow, SetupWindow, MassUpload, UpdateDatabase]", variable has type "UpdateDatabase")
        cls.update_window = cls.pc.select_frame(UpdateDatabase)  # type: ignore
        return super().setUpClass()
    def __enter__(self) -> Database:
        logger.info(f'Entering database context.')

        self.context = True

        if not os.path.exists(DatabasePath.get()):
            self.create_db = True

        self.connection = sqlite3.connect(DatabasePath.get())
        self.cursor = self.connection.cursor()

        if self.create_db:
            self.create_database()

        return self
Beispiel #5
0
def remove_db_file() -> None:
    """ Function to remove a database file if it exists.

    This function uses the DatabasePath class from `S3_File_Uploader.__init__.py` to determine what
    database file to remove.
    """
    # Have to create an instance variable of DatabasePath since the tests create different databases
    #   depending on the test that is running.
    # I tested by just entering `DatabasePath.get()` in the os commands bellow and the tests fail.
    db_file_path = DatabasePath.get()

    if os.path.exists(db_file_path):
        # Since the tests run faster than what Python can remove the file,
        #  the function is now recursive to wait until the program actually ends
        #  before removing the database file.
        try:
            os.remove(db_file_path)
        except PermissionError:
            time.sleep(1)
            remove_db_file()
    def setUpClass(cls) -> None:
        DatabasePath.change_path(
            os.path.join(os.getcwd(), 'main_window_test_db.sqlite3'))

        remove_db_file()
        return super().setUpClass()