File size: 2,256 Bytes
99a46bd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
58
59
60
"""Regression tests for the bilingual microdataset validator.

SPDX-License-Identifier: MIT
"""

from __future__ import annotations

import copy
import unittest

from validate_iceland import (
    DEFAULT_DATA,
    _read_jsonl,
    validate_records,
    validate_repository,
)


class MicrodatasetValidationTests(unittest.TestCase):
    @classmethod
    def setUpClass(cls) -> None:
        cls.records, cls.read_errors = _read_jsonl(DEFAULT_DATA)

    def test_release_candidate_is_structurally_valid(self) -> None:
        self.assertEqual(self.read_errors, [])
        self.assertEqual(validate_repository(), [])

    def test_missing_translation_breaks_pair_completeness(self) -> None:
        errors = validate_records(copy.deepcopy(self.records[:-1]))
        self.assertTrue(any("exactly 24 records" in error for error in errors))
        self.assertTrue(any("exactly one pt-BR and one en" in error for error in errors))

    def test_pluralism_cannot_be_disabled(self) -> None:
        records = copy.deepcopy(self.records)
        records[0]["pluralism"]["required"] = False
        errors = validate_records(records)
        self.assertTrue(any("pluralism safeguard must be required" in error for error in errors))

    def test_incomplete_review_focus_is_rejected(self) -> None:
        records = copy.deepcopy(self.records)
        records[0]["creation"]["review_focus"] = ["cultural-sensitivity"]
        errors = validate_records(records)
        self.assertTrue(any("review_focus is incomplete" in error for error in errors))

    def test_malformed_creation_object_is_reported_without_crashing(self) -> None:
        records = copy.deepcopy(self.records)
        records[0]["creation"] = {"method": "ai-generated-original-draft"}
        errors = validate_records(records)
        self.assertTrue(any("invalid creation object" in error for error in errors))

    def test_universalizing_religious_claim_is_rejected(self) -> None:
        records = copy.deepcopy(self.records)
        records[0]["perspectives"][0]["argument"] += " All Christians believe this."
        errors = validate_records(records)
        self.assertTrue(any("prohibited universalizing" in error for error in errors))


if __name__ == "__main__":
    unittest.main()