Skip to content

Commit

Permalink
add script for test_2_loading_saved_files
Browse files Browse the repository at this point in the history
  • Loading branch information
h0anle committed Sep 26, 2024
1 parent 44898a2 commit 298d0af
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/visualisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ def load(self, file_path):
self.original_dfs[k] = pd.read_csv(StringIO(csv_data))

self.update_dfs_list()

# Load plots
plots_data = load.get('plots', {})
for graph_id, graph_data in plots_data.items():
Expand Down
33 changes: 33 additions & 0 deletions examples/ex_loading_saved_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import sys
import os
from pathlib import Path

from PySide6.QtWidgets import QApplication
from PySide6.QtGui import QIcon

from app.main import Main

def ex_loading_saved_files(run_app=True):
"""Example of reading different supported .CSV and .txt data formats"""

DATA_DIR = Path(__file__).parent
file_paths = [str(file) for ext in ['*.maps', '*.spectra'] for file in DATA_DIR.glob(ext)]

app = QApplication.instance() or QApplication([])
window = Main()
app.setStyle("Fusion")

if file_paths is None or len(file_paths) == 0:
raise ValueError("No valid file paths provided.")
try:
window.open(file_paths=file_paths)
except Exception as e:
raise RuntimeError(f"Failed to open files: {e}")

window.ui.show()

if run_app:
sys.exit(app.exec())

if __name__ == "__main__":
ex_loading_saved_files()
6 changes: 0 additions & 6 deletions tests/test_2.py

This file was deleted.

11 changes: 11 additions & 0 deletions tests/test_2_loading_saved_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Test_1
import sys
from pathlib import Path

sys.path.insert(0, str(Path(__file__).resolve().parent.parent))

import pytest
from examples.ex_loading_saved_files import ex_loading_saved_files

def test_loading_saved_files(qtbot):
ex_loading_saved_files(run_app=False)

0 comments on commit 298d0af

Please sign in to comment.