aboutsummaryrefslogtreecommitdiffstats
path: root/test_upscale_qt.py
diff options
context:
space:
mode:
Diffstat (limited to 'test_upscale_qt.py')
-rw-r--r--test_upscale_qt.py37
1 files changed, 17 insertions, 20 deletions
diff --git a/test_upscale_qt.py b/test_upscale_qt.py
index 1fbfe2c..cb11346 100644
--- a/test_upscale_qt.py
+++ b/test_upscale_qt.py
@@ -30,20 +30,6 @@ _loader.exec_module(uq)
from PyQt6.QtGui import QColor, QImage, QImageReader # noqa: E402
-NAMES = ['4x_detail.pth', 'RealESRGAN_x4plus.pth',
- 'RealESRGAN_x4plus_anime_6B.pth']
-
-
-def test_match_model():
- m = uq.match_model
- # the longer stem must win over its own prefix
- assert m('RealESRGAN_x4plus_anime_6B.pth', NAMES) == 'RealESRGAN_x4plus_anime_6B.pth'
- assert m(' realesrgan_x4plus\n', NAMES) == 'RealESRGAN_x4plus.pth'
- assert m('I suggest 4x_detail.', NAMES) == '4x_detail.pth'
- assert m('no idea', NAMES) is None
- assert m('', []) is None
-
-
def test_list_models():
d = os.path.join(TMP, 'models')
os.makedirs(d)
@@ -53,15 +39,25 @@ def test_list_models():
assert uq.list_models(os.path.join(TMP, 'missing')) == []
+def test_descriptions():
+ d = os.path.join(TMP, 'models')
+ with open(os.path.join(d, 'models.txt'), 'w') as f:
+ f.write('# comment = ignored\n'
+ 'a.pth = Clean photos: people, nature\n'
+ '\n'
+ 'no separator here\n'
+ ' c.GGUF=Anime \n')
+ desc = uq.read_descriptions(d)
+ assert desc == {'a.pth': 'Clean photos: people, nature', 'c.GGUF': 'Anime'}
+ assert uq.model_label('a.pth', desc) == 'Clean photos: people, nature [a]'
+ assert uq.model_label('b.safetensors', desc) == 'b.safetensors'
+ assert uq.read_descriptions(os.path.join(TMP, 'missing')) == {}
+
+
def test_args():
a = uq.sd_args('/m/x.pth', '/in.png', '/out.png')
assert a == ['-M', 'upscale', '--upscale-model', '/m/x.pth',
'-i', '/in.png', '-o', '/out.png']
- a = uq.llama_args('/m.gguf', '/mm.gguf', '/in.png', NAMES)
- assert a[a.index('--image') + 1] == '/in.png'
- prompt = a[a.index('-p') + 1]
- assert all(n in prompt for n in NAMES)
- assert 'noise' in prompt
def test_save_over():
@@ -98,7 +94,6 @@ def test_compare_view():
def test_main_window():
w = uq.Main()
- w.cfg.setValue('imajev_model', '') # never run the real VLM in tests
w.cfg.setValue('upscalers_dir', os.path.join(TMP, 'models'))
w.reload_models()
assert not w.a_up.isEnabled() # no image yet
@@ -110,6 +105,8 @@ def test_main_window():
assert len(w.jobs) == 1 and w.jobs[0].image.size() == img.size()
assert os.path.exists(w.jobs[0].input)
assert w.a_up.isEnabled() and not w.a_save.isEnabled()
+ assert w.models.itemText(0) == 'Clean photos: people, nature [a]'
+ assert w.models.currentData() == 'a.pth'
if __name__ == '__main__':