aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/register/tests/test_css.py
blob: fe530bd01a47e0b2f1ecc253aa548bad9b356ce6 (plain) (blame)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import pytest

from ctrack.register.css import Swimlane
from ctrack.register.models import CAFSingleDateEvent, EventType

pytestmark = pytest.mark.django_db


@pytest.mark.parametrize(
    "e_type,css_str,id_str",
    [
        (
            EventType.CAF_INITIAL_CAF_RECEIVED.name,
            ' style="background-color: green; color: white;"',
            "caf-initial-received-event",
        ),
        (
            EventType.CAF_INITIAL_REVIEW_COMPLETE.name,
            ' style="background-color: green; color: white;"',
            "caf-initial-review-complete-event",
        ),
    ],
)
def test_can_get_class_string(caf, user, e_type, css_str, id_str):
    org_name = caf.organisation.name
    event = CAFSingleDateEvent.objects.create(
        type_descriptor=e_type, related_caf=caf, date="2020-10-20", user=user
    )
    sl = Swimlane(org_name, [event])
    assert sl.tag_attrs(event).inline_style == css_str
    assert sl.tag_attrs(event).id_str == id_str


def test_progress_chart_css_initial_review_only(caf, user):
    accept = ("<tr>\n"
              "<td>{}</td>\n"
              "<td style=\"background-color: green; color: white;\">CAF_INITIAL_CAF_RECEIVED</td>\n"
              "<td>CAF_INITIAL_REVIEW_COMPLETE</td>\n"
              "<td>CAF_FEEDBACK_EMAILED_OES</td>\n"
              "<td>CAF_RECEIVED</td>\n"
              "<td>CAF_EMAILED_ROSA</td>\n"
              "<td>CAF_VALIDATION_SIGN_OFF</td>\n"
              "<td>CAF_VALIDATION_RECORD_EMAILED_TO_OES</td>\n"
              "<td>CAF_PEER_REVIEW_PERIOD</td>\n"
              "<td>CAF_VALIDATION_PERIOD</td>\n"
              "</tr>")
    org_name = caf.organisation.name
    caf_initial = CAFSingleDateEvent.objects.create(
        type_descriptor=EventType.CAF_INITIAL_CAF_RECEIVED.name,
        related_caf=caf,
        date="2020-10-20",
        user=user,
    )
    output = Swimlane(org_name, [caf_initial])
    assert output.tr == accept.format(org_name)


def test_progress_chart_css_initial_two_events(caf, user):
    accept = ("<tr>\n"
              "<td>{}</td>\n"
              "<td style=\"background-color: green; color: white;\">CAF_INITIAL_CAF_RECEIVED</td>\n"
              "<td style=\"background-color: green; color: white;\">CAF_INITIAL_REVIEW_COMPLETE</td>\n"
              "<td>CAF_FEEDBACK_EMAILED_OES</td>\n"
              "<td>CAF_RECEIVED</td>\n"
              "<td>CAF_EMAILED_ROSA</td>\n"
              "<td>CAF_VALIDATION_SIGN_OFF</td>\n"
              "<td>CAF_VALIDATION_RECORD_EMAILED_TO_OES</td>\n"
              "<td>CAF_PEER_REVIEW_PERIOD</td>\n"
              "<td>CAF_VALIDATION_PERIOD</td>\n"
              "</tr>")
    org_name = caf.organisation.name
    caf_initial = CAFSingleDateEvent.objects.create(
        type_descriptor=EventType.CAF_INITIAL_CAF_RECEIVED.name,
        related_caf=caf,
        date="2020-10-20",
        user=user,
    )
    caf_reviewed = CAFSingleDateEvent.objects.create(
        type_descriptor=EventType.CAF_INITIAL_REVIEW_COMPLETE.name,
        related_caf=caf,
        date="2020-10-20",
        user=user,
    )
    output = Swimlane(org_name, [caf_initial, caf_reviewed])
    assert output.tr == accept.format(org_name)


def test_progress_chart_css_second_event(caf, user):
    accept = ("<tr>\n"
              "<td>{}</td>\n"
              "<td>CAF_INITIAL_CAF_RECEIVED</td>\n"
              "<td style=\"background-color: green; color: white;\">CAF_INITIAL_REVIEW_COMPLETE</td>\n"
              "<td>CAF_FEEDBACK_EMAILED_OES</td>\n"
              "<td>CAF_RECEIVED</td>\n"
              "<td>CAF_EMAILED_ROSA</td>\n"
              "<td>CAF_VALIDATION_SIGN_OFF</td>\n"
              "<td>CAF_VALIDATION_RECORD_EMAILED_TO_OES</td>\n"
              "<td>CAF_PEER_REVIEW_PERIOD</td>\n"
              "<td>CAF_VALIDATION_PERIOD</td>\n"
              "</tr>")
    org_name = caf.organisation.name
    caf_reviewed = CAFSingleDateEvent.objects.create(
        type_descriptor=EventType.CAF_INITIAL_REVIEW_COMPLETE.name,
        related_caf=caf,
        date="2020-10-20",
        user=user,
    )
    output = Swimlane(org_name, [caf_reviewed])
    assert output.tr == accept.format(org_name)


def test_table_row_builder(user, caf):
    e1 = CAFSingleDateEvent.objects.create(
        type_descriptor=EventType.CAF_INITIAL_CAF_RECEIVED.name,
        related_caf=caf,
        date="2020-10-20",
        user=user,
    )
    e2 = CAFSingleDateEvent.objects.create(
        type_descriptor=EventType.CAF_INITIAL_REVIEW_COMPLETE.name,
        related_caf=caf,
        date="2020-10-20",
        user=user,
    )
    org_name = caf.organisation.name
    sl = Swimlane(org_name, [e1, e2])
    assert sl.table_row_builder() == (
        "<tr>\n"
        f"<td>{caf.organisation.name}</td>\n"
        '<td style="background-color: green; color: white;">CAF_INITIAL_CAF_RECEIVED</td>\n'
        '<td style="background-color: green; color: white;">CAF_INITIAL_REVIEW_COMPLETE</td>\n'
        "<td>CAF_FEEDBACK_EMAILED_OES</td>\n"
        "<td>CAF_RECEIVED</td>\n"
        "<td>CAF_EMAILED_ROSA</td>\n"
        "<td>CAF_VALIDATION_SIGN_OFF</td>\n"
        "<td>CAF_VALIDATION_RECORD_EMAILED_TO_OES</td>\n"
        "<td>CAF_PEER_REVIEW_PERIOD</td>\n"
        "<td>CAF_VALIDATION_PERIOD</td>\n"
        "</tr>"
    )