File size: 1,852 Bytes
e8055cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""Tests for encoder/config.py -- cache and spatial-code path helpers."""

import pytest

from encoder import config


def test_encoder_paths_mirror_all_dimensions(tmp_path, monkeypatch):
    monkeypatch.setattr(config, "CACHE_ROOT", tmp_path / "caches")
    monkeypatch.setattr(config, "CODES_ROOT", tmp_path / "codes")
    assert config.cache_file("scene", "metric", "uniform", "no tracking", 64).endswith(
        "no tracking/frames/uniform/64/scene.pkl.gz"
    )
    assert config.da3_cache_file("scene", "relative", "uniform", 32).endswith(
        "depth-anything-3/relative/frames/uniform/32/scene.pkl"
    )
    assert config.video_da3_cache_file("scene").endswith(
        "depth-anything-3/metric/video/scene.npz"
    )
    assert config.video_da3_cache_file("scene", "relative").endswith(
        "depth-anything-3/relative/video/scene.npz"
    )
    assert config.video_sam3_cache_file("scene").endswith(
        "sam3/no tracking/video/scene.pkl.gz"
    )
    assert config.video_sam3_cache_file("scene", "tracking").endswith(
        "sam3/tracking/video/scene.pkl.gz"
    )
    assert config.spatial_code_path(
        "scene", "metric", "selective", "tracking", 64
    ).endswith("tracking/frames/selective/64/explicit/scene.json")
    assert config.spatial_code_path(
        "scene", "relative", "uniform", "no tracking", 96, "compact"
    ).endswith("no tracking/frames/uniform/96/compact/scene.json")
    assert config.spatial_code_path(
        "scene", "metric", config.VIDEO_INPUT_SELECTION, "no tracking", None, "explicit"
    ).endswith("no tracking/video/explicit/scene.json")


def test_encoder_paths_reject_unknown_spatial_code_format():
    with pytest.raises(ValueError, match="unknown spatial-code format"):
        config.spatial_code_path(
            "scene", "metric", "uniform", "tracking", 32, "unknown"
        )