File size: 1,886 Bytes
4949db9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
46
47
48
49
50
51
52
53
54
55
56
57
import pytest


def _make_eval_json(results, judge="gemini"):
    return {
        "schema_version": "v2.0",
        "judge": judge,
        "results": results,
    }


def _make_result(video, domain, prompt, scores=None):
    base = {"video": video, "domain": domain, "prompt": prompt}
    if scores:
        base.update(scores)
    return base


class TestImportHash:
    def test_deterministic(self, tmp_path):
        from human_eval.import_videos import compute_import_hash
        (tmp_path / "ds1").mkdir()
        (tmp_path / "ds1" / "a.mp4").touch()
        (tmp_path / "ds1" / "b.mp4").touch()
        h1 = compute_import_hash(tmp_path)
        h2 = compute_import_hash(tmp_path)
        assert h1 == h2

    def test_changes_with_files(self, tmp_path):
        from human_eval.import_videos import compute_import_hash
        (tmp_path / "ds1").mkdir()
        (tmp_path / "ds1" / "a.mp4").touch()
        h1 = compute_import_hash(tmp_path)
        (tmp_path / "ds1" / "b.mp4").touch()
        h2 = compute_import_hash(tmp_path)
        assert h1 != h2


class TestDifficultyScore:
    def test_computes_mean_abs_diff(self):
        from human_eval.import_videos import compute_difficulty_score
        gemini = {"SA": 4, "PTV": 3, "persistence": 4}
        qwen = {"SA": 2, "PTV": 1, "persistence": 2}
        score = compute_difficulty_score(gemini, qwen)
        assert abs(score - 6 / 3) < 1e-6

    def test_returns_none_when_missing_keys(self):
        from human_eval.import_videos import compute_difficulty_score
        assert compute_difficulty_score({"SA": 1}, {}) is None


class TestImportVideos:
    def test_importer_disabled_without_prompt_selection_json(self, db, tmp_path):
        from human_eval.import_videos import import_videos
        with pytest.raises(RuntimeError, match="prompt-selection JSON"):
            import_videos(db, tmp_path / "videos")