File size: 1,911 Bytes
3ed6a4c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f2cc7bd
 
 
 
 
 
 
 
 
 
 
 
 
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
61
62
63
from review_table_config import (
    MAIN_REVIEW_COLUMNS,
    TECHNICAL_REVIEW_COLUMNS,
    hidden_technical_columns,
    main_review_columns,
    technical_display_columns,
)


def test_main_review_columns_are_limited_to_user_facing_edit_fields():
    assert MAIN_REVIEW_COLUMNS == [
        "include",
        "remember",
        "review_status_label",
        "find",
        "replace_with",
        "type_label",
        "confidence",
    ]


def test_technical_columns_are_not_in_main_review_columns():
    for column in TECHNICAL_REVIEW_COLUMNS:
        assert column not in MAIN_REVIEW_COLUMNS


def test_main_review_columns_only_returns_existing_columns():
    available = ["include", "find", "replace_with", "source", "score"]
    assert main_review_columns(available) == ["include", "find", "replace_with"]


def test_technical_display_columns_preserve_audit_fields_when_available():
    available = [
        "review_status_label",
        "find",
        "type_label",
        "source_label",
        "reason",
        "context",
        "entity_type",
        "score",
        "source",
    ]
    assert technical_display_columns(available) == available


def test_hidden_technical_columns_only_returns_existing_technical_columns():
    available = ["include", "source_label", "reason", "score", "replace_with"]
    assert hidden_technical_columns(available) == ["source_label", "reason", "score"]


def test_column_helpers_accept_pandas_index_like_objects_without_truth_value_check():
    class PandasIndexLike:
        def __iter__(self):
            return iter(["include", "find", "replace_with", "score"])

        def __bool__(self):
            raise ValueError("The truth value of a Index is ambiguous")

    available = PandasIndexLike()
    assert main_review_columns(available) == ["include", "find", "replace_with"]
    assert technical_display_columns(available) == ["find", "score"]