fix: refuse unavailable gallery and pin head trainer
This commit is contained in:
parent
d5a7a56dff
commit
ac315eb48e
4 changed files with 77 additions and 6 deletions
|
|
@ -274,6 +274,33 @@ class CatalogTests(unittest.TestCase):
|
|||
self.assertEqual(product["number_out"], 3)
|
||||
self.assertIsNone(engine.update_stock("nope", -1))
|
||||
|
||||
|
||||
class GalleryLoadTests(unittest.TestCase):
|
||||
def test_a_failed_gallery_load_returns_none_and_is_not_retried(self):
|
||||
engine, _, _, _ = make_engine(identity_backend="gallery", stock_dir="does-not-exist")
|
||||
|
||||
class BrokenGallery:
|
||||
def __init__(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
def load(self):
|
||||
raise FileNotFoundError("DINOv2 weights not found")
|
||||
|
||||
import gallery as gallery_module
|
||||
|
||||
original = gallery_module.ProductGallery
|
||||
gallery_module.ProductGallery = BrokenGallery
|
||||
try:
|
||||
self.assertIsNone(engine.identity_gallery())
|
||||
self.assertIsNone(engine.identity_gallery())
|
||||
finally:
|
||||
gallery_module.ProductGallery = original
|
||||
engine.shutdown()
|
||||
self.assertIs(engine._gallery, False)
|
||||
|
||||
|
||||
|
||||
class CatalogImageTests(unittest.TestCase):
|
||||
def test_catalog_image_path_is_resolved_through_inventory(self):
|
||||
engine, _, _, _ = make_engine()
|
||||
self.assertIsNone(engine.catalog_image_path("../../etc/passwd"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue