From b283aa418a1c0016a63a328fec6259dfe110cefe Mon Sep 17 00:00:00 2001 From: Brianna Rainey Date: Thu, 29 Jan 2026 16:30:43 -0500 Subject: fix `settings.ini` not located in correct path --- tests/__init__.py | 2 +- tests/data/config/projects/testproject.avp | 17 +++++++++++++++++ tests/data/projects/testproject.avp | 17 ----------------- tests/test_core_init.py | 13 +++++++++++++ tests/test_mainwindow_projects.py | 12 +++++++++++- 5 files changed, 42 insertions(+), 19 deletions(-) create mode 100644 tests/data/config/projects/testproject.avp delete mode 100644 tests/data/projects/testproject.avp (limited to 'tests') diff --git a/tests/__init__.py b/tests/__init__.py index df08c7c..bb35f72 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -43,7 +43,7 @@ def getTestDataPath(filename=""): def initCore(): - testDataDir = getTestDataPath() + testDataDir = getTestDataPath("config") unwanted = ["autosave.avp", "settings.ini"] for file in unwanted: filename = os.path.join(testDataDir, "autosave.avp") diff --git a/tests/data/config/projects/testproject.avp b/tests/data/config/projects/testproject.avp new file mode 100644 index 0000000..9639716 --- /dev/null +++ b/tests/data/config/projects/testproject.avp @@ -0,0 +1,17 @@ +[Components] +Classic Visualizer +1 +OrderedDict({'bars': 63, 'layout': 0, 'preset': None, 'scale': 20, 'smooth': 0, 'visColor': (255, 255, 255), 'y': 0.0}) +Color +1 +OrderedDict({'LG_end': 0.0, 'LG_start': 0.0, 'RG_centre': 0.0015625, 'RG_end': 0.0, 'RG_start': 0.0, 'color1': (0, 0, 0), 'color2': (133, 133, 133), 'fillType': 0, 'height': 1.0, 'preset': None, 'spread': 0, 'stretch': False, 'trans': False, 'width': 1.0, 'x': 0.0, 'y': 0.0}) + +[Settings] +componentDir=tests/data/inputfiles +inputDir=tests/data/inputfiles +presetDir=tests/data/config/presets +projectDir=tests/data/config/projects + +[WindowFields] +lineEdit_audioFile=tests/data/inputfiles/test.ogg +lineEdit_outputFile= diff --git a/tests/data/projects/testproject.avp b/tests/data/projects/testproject.avp deleted file mode 100644 index fd6b6eb..0000000 --- a/tests/data/projects/testproject.avp +++ /dev/null @@ -1,17 +0,0 @@ -[Components] -Classic Visualizer -1 -OrderedDict({'bars': 63, 'layout': 0, 'preset': None, 'scale': 20, 'smooth': 0, 'visColor': (255, 255, 255), 'y': 0.0}) -Color -1 -OrderedDict({'LG_end': 0.0, 'LG_start': 0.0, 'RG_centre': 0.0015625, 'RG_end': 0.0, 'RG_start': 0.0, 'color1': (0, 0, 0), 'color2': (133, 133, 133), 'fillType': 0, 'height': 1.0, 'preset': None, 'spread': 0, 'stretch': False, 'trans': False, 'width': 1.0, 'x': 0.0, 'y': 0.0}) - -[Settings] -componentDir=tests/data/inputfiles -inputDir=tests/data/inputfiles -presetDir=tests/data/presets -projectDir=tests/data/projects - -[WindowFields] -lineEdit_audioFile=tests/data/test.ogg -lineEdit_outputFile= diff --git a/tests/test_core_init.py b/tests/test_core_init.py index 16606fb..e1f2dbb 100644 --- a/tests/test_core_init.py +++ b/tests/test_core_init.py @@ -1,7 +1,10 @@ +import os from avp.core import Core +from . import getTestDataPath, initCore def test_component_names(): + initCore() core = Core() assert core.compNames == [ "Classic Visualizer", @@ -17,5 +20,15 @@ def test_component_names(): def test_moduleindex(): + initCore() core = Core() assert core.moduleIndexFor("Classic Visualizer") == 0 + + +def test_configPath_default(): + configPath = Core.getConfigPath(None) + assert os.path.basename(configPath) == "audio-visualizer" + + +def test_configPath_nonstandard(): + assert Core.getConfigPath(getTestDataPath("config")) == getTestDataPath("config") diff --git a/tests/test_mainwindow_projects.py b/tests/test_mainwindow_projects.py index 8ad491a..6b49799 100644 --- a/tests/test_mainwindow_projects.py +++ b/tests/test_mainwindow_projects.py @@ -1,3 +1,5 @@ +from PyQt6 import QtCore +import os from pytest import fixture from pytestqt import qtbot from . import getTestDataPath, window @@ -8,9 +10,17 @@ def test_mainwindow_clear(qtbot, window): assert len(window.core.selectedComponents) == 0 +def test_mainwindow_presetDir_in_tests(qtbot, window): + # FIXME presetDir gets set to projectDir for some reason + assert ( + os.path.basename(os.path.dirname(window.core.settings.value("presetDir"))) + == "config" + ) + + def test_mainwindow_openProject(qtbot, window): """Open testproject.avp using MainWindow.openProject()""" - window.openProject(getTestDataPath("projects/testproject.avp"), prompt=False) + window.openProject(getTestDataPath("config/projects/testproject.avp"), prompt=False) assert len(window.core.selectedComponents) == 2 -- cgit v1.2.3