fix(backend): keep fig-/feat- tags by slug, not just name
The live store marks the figure/feature tag families on the tag SLUG
(slug 'fig-chat', display name 'Chatoyant'), but _scoped_tags filtered on
name.startswith('fig-'), so all 11 fig-* tags were silently dropped at sync
and the figure-tag echo (METADATA-30) had nothing to draw from. Match the
prefix on slug OR name. Adds a test for the slug-prefixed bare-name shape.
This commit is contained in:
@@ -145,6 +145,24 @@ def test_sync_populates_scoped(db_dir):
|
||||
assert conn.execute("SELECT value FROM settings WHERE key='taxonomy_last_sync_at'").fetchone()[0]
|
||||
|
||||
|
||||
def test_sync_keeps_slug_prefixed_bare_name_tags(db_dir):
|
||||
# Live-store shape: the fig- family marker is on the SLUG, the display name
|
||||
# is bare (slug 'fig-chat', name 'Chatoyant'). These must be kept.
|
||||
tags = (200, {"X-WP-TotalPages": "1"}, json.dumps([
|
||||
{"id": 300, "name": "Birdseye", "slug": "fig-brdseye", "woo_id": 300},
|
||||
{"id": 310, "name": "Chatoyant", "slug": "fig-chat", "woo_id": 310},
|
||||
{"id": 500, "name": "Knot", "slug": "feat-knot", "woo_id": 500},
|
||||
{"id": 600, "name": "Rustic", "slug": "rustic", "woo_id": 600}, # bare non-fig: dropped
|
||||
]).encode())
|
||||
cats = (200, {"X-WP-TotalPages": "1"}, json.dumps([{"id": 1, "name": "Cedar", "slug": "cedar", "parent_id": None, "woo_id": 10}]).encode())
|
||||
attrs = (200, {"X-WP-TotalPages": "1"}, json.dumps([]).encode())
|
||||
c, _ = _client([cats, tags, attrs])
|
||||
taxonomy_mod.sync(c, db_mod.get_connection())
|
||||
conn = db_mod.get_connection()
|
||||
tag_ids = {r[0] for r in conn.execute("SELECT id FROM woo_tags")}
|
||||
assert tag_ids == {300, 310, 500} # slug-prefixed fig/feat kept, bare 'rustic' dropped
|
||||
|
||||
|
||||
def test_sync_failure_keeps_previous_cache(db_dir):
|
||||
conn = db_mod.get_connection()
|
||||
conn.execute("INSERT INTO woo_categories(id,name,slug,parent_id,woo_id) VALUES (99,'Old','old',NULL,1)")
|
||||
|
||||
Reference in New Issue
Block a user