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 --- .gitignore | 6 +++--- pyproject.toml | 2 +- src/avp/__init__.py | 2 +- src/avp/core.py | 21 ++++++++++++++------- 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 +++++++++++- uv.lock | 2 +- 10 files changed, 62 insertions(+), 32 deletions(-) create mode 100644 tests/data/config/projects/testproject.avp delete mode 100644 tests/data/projects/testproject.avp diff --git a/.gitignore b/.gitignore index 278948f..5f7cabb 100644 --- a/.gitignore +++ b/.gitignore @@ -9,9 +9,9 @@ prof/ .venv/ .env/ .vscode/ -tests/data/log/ -tests/data/settings.ini -tests/data/autosave.avp +tests/data/config/log/ +tests/data/config/settings.ini +tests/data/config/autosave.avp *.mkv *.mp4 *.wav diff --git a/pyproject.toml b/pyproject.toml index ea27839..2d604f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "uv_build" name = "audio-visualizer-python" description = "Create audio visualization videos from a GUI or commandline" readme = "README.md" -version = "2.2.2" +version = "2.2.3" requires-python = ">= 3.12" license = "MIT" classifiers=[ diff --git a/src/avp/__init__.py b/src/avp/__init__.py index 9de9f93..8783660 100644 --- a/src/avp/__init__.py +++ b/src/avp/__init__.py @@ -3,7 +3,7 @@ import os import logging -__version__ = "2.2.2" +__version__ = "2.2.3" class Logger(logging.getLoggerClass()): diff --git a/src/avp/core.py b/src/avp/core.py index 1e9a9c3..347a5dd 100644 --- a/src/avp/core.py +++ b/src/avp/core.py @@ -426,13 +426,7 @@ class Core: from .toolkit.ffmpeg import findFfmpeg cls.wd = wd - dataDir = ( - QtCore.QStandardPaths.writableLocation( - QtCore.QStandardPaths.StandardLocation.AppConfigLocation - ) - if dataDir is None - else dataDir - ) + dataDir = cls.getConfigPath(dataDir) # Windows: C:/Users//AppData/Local/audio-visualizer # macOS: ~/Library/Preferences/audio-visualizer # Linux: ~/.config/audio-visualizer @@ -593,3 +587,16 @@ class Core: libLog.addHandler(libLogFile) # lowest level must be explicitly set on the root Logger libLog.setLevel(0) + + @staticmethod + def getConfigPath(dataDir=None): + return ( + os.path.join( + QtCore.QStandardPaths.writableLocation( + QtCore.QStandardPaths.StandardLocation.AppConfigLocation + ), + "audio-visualizer", + ) + if dataDir is None + else dataDir + ) 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 diff --git a/uv.lock b/uv.lock index a23039a..e403a68 100644 --- a/uv.lock +++ b/uv.lock @@ -4,7 +4,7 @@ requires-python = ">=3.12" [[package]] name = "audio-visualizer-python" -version = "2.2.2" +version = "2.2.3" source = { editable = "." } dependencies = [ { name = "numpy" }, -- cgit v1.2.3