Spaces:
Paused

Malina Claude Opus 5 (1M context) commited on
Commit
cadec28
·
1 Parent(s): 759c848

Test pilnuje, zeby mapa rozszerzen nie rozjechala sie miedzy repozytoriami

Browse files

Mapa rozszerzenie -> kategoria zyje w dwoch kopiach: extract.py tutaj i EXT
w luna.js po stronie strony. Decyduje o tym, ktory limit rozmiaru obowiazuje
dla pliku, wiec identycznosc dzisiaj nie jest pointa - pointa jest to, ze
jedna strone mozna wyedytowac samotnie i nikt tego nie zauwazy. Wlasnie tak
sie stalo wczoraj, gdy dodalem tu kategorie vector dla SVG.

Dwa testy: obie mapy musza zawierac te same rozszerzenia z tymi samymi
kategoriami, i kazda kategoria, ktora Space potrafi zwrocic, musi miec
etykiete w kreatorze. Pomijaja sie same tam, gdzie repozytorium strony nie
jest wypakowane, wiec na Space nie przeszkadzaja.

Sprawdzone, ze naprawde lapia: usuniecie svg z jednej strony czerwieni test,
przywrocenie zieleni.

Testy: 58 -> 60.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

Files changed (1) hide show
  1. test_luna.py +44 -0
test_luna.py CHANGED
@@ -596,3 +596,47 @@ def test_salvage_unescapes_what_it_recovers():
596
  got = _salvage(raw)
597
  assert got is not None
598
  assert "\n" in got["notes"] and '"cytatem"' in got["notes"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
596
  got = _salvage(raw)
597
  assert got is not None
598
  assert "\n" in got["notes"] and '"cytatem"' in got["notes"]
599
+
600
+
601
+ # --- the two copies of the extension map ---------------------------------------
602
+
603
+ _LUNA_JS = os.path.expanduser("~/Dokumenty/NNLABS.PL/WEBSITE/APP_WEBSITE/js/luna.js")
604
+
605
+
606
+ def test_the_browser_and_the_space_agree_on_file_categories():
607
+ """The map lives twice, here and in the wizard, and it decides which size limit
608
+ applies to a file. Identical today is not the point; the point is that one side
609
+ can be edited alone. Skipped where the website repo is not checked out."""
610
+ import re
611
+ import pytest as _pt
612
+ if not os.path.exists(_LUNA_JS):
613
+ _pt.skip("website repo not present")
614
+
615
+ import extract
616
+ js = open(_LUNA_JS, encoding="utf-8").read()
617
+ block = re.search(r"const EXT = \{(.*?)\n\};", js, re.S)
618
+ assert block, "could not find the EXT map in luna.js"
619
+ front = dict(re.findall(r'([a-z0-9]+)\s*:\s*"([a-z]+)"', block.group(1)))
620
+
621
+ assert front, "parsed an empty map from luna.js"
622
+ missing_in_front = sorted(set(extract._EXT) - set(front))
623
+ missing_in_space = sorted(set(front) - set(extract._EXT))
624
+ disagree = sorted(k for k in set(front) & set(extract._EXT)
625
+ if front[k] != extract._EXT[k])
626
+ assert not missing_in_front, f"the wizard does not know: {missing_in_front}"
627
+ assert not missing_in_space, f"the Space does not know: {missing_in_space}"
628
+ assert not disagree, f"different categories: {disagree}"
629
+
630
+
631
+ def test_every_category_the_space_can_return_has_a_label_in_the_wizard():
632
+ import re
633
+ import pytest as _pt
634
+ if not os.path.exists(_LUNA_JS):
635
+ _pt.skip("website repo not present")
636
+ import extract
637
+ js = open(_LUNA_JS, encoding="utf-8").read()
638
+ cat = re.search(r"const CAT = \{(.*?)\n\};", js, re.S)
639
+ assert cat, "could not find the CAT map in luna.js"
640
+ labelled = set(re.findall(r"([a-z]+)\s*:\s*\[", cat.group(1)))
641
+ used = set(extract._EXT.values()) | {"other"}
642
+ assert not (used - labelled), f"no label for: {sorted(used - labelled)}"