diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-22 14:25:07 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-22 14:25:07 +0100 |
commit | 9a7d578b12ca6f869f7561f11ee0837a12b58a84 (patch) | |
tree | e5e645af0b6858bc603caa2f3f95335bf4e44050 /ctrack/register/tests/test_css.py | |
parent | 113f9483a2b2863f3e7e176285e9031593843eda (diff) |
failing tests but lots of progress on html builders
Diffstat (limited to '')
-rw-r--r-- | ctrack/register/tests/test_css.py | 126 |
1 files changed, 80 insertions, 46 deletions
diff --git a/ctrack/register/tests/test_css.py b/ctrack/register/tests/test_css.py index 8c9f77a..301c715 100644 --- a/ctrack/register/tests/test_css.py +++ b/ctrack/register/tests/test_css.py @@ -1,6 +1,6 @@ import pytest -from ctrack.register.css import tag_attrs, Swimlane, CAFSwimlaneSlots +from ctrack.register.css import Swimlane from ctrack.register.models import CAFSingleDateEvent, EventType pytestmark = pytest.mark.django_db @@ -11,54 +11,39 @@ pytestmark = pytest.mark.django_db [ ( EventType.CAF_INITIAL_CAF_RECEIVED.name, - 'style="background-color: green; color: white;"', + ' style="background-color: green; color: white;"', "caf-initial-received-event", ), ( EventType.CAF_INITIAL_REVIEW_COMPLETE.name, - 'style="background-color: green; color: white;"', + ' 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 ) - assert tag_attrs(event).inline_style == css_str - assert tag_attrs(event).id_str == id_str - - -class _TestEvent(CAFSingleDateEvent): - def __init__(self, event): - self.type_descriptor = event - - -def test_swimlane_slots(): - slots = CAFSwimlaneSlots( - initial_submitted=_TestEvent("CAF Initial Submitted"), - # reviewed=_TestEvent("CAF Reviewed"), - # revisions_submitted=_TestEvent("CAF Revisions Submitted"), - # validation_agreed=_TestEvent("CAF Validation Agreed"), - # improvement_plan_submitted=_TestEvent("Improvement Plan Submitted"), - # improvement_plan_reviewed=_TestEvent("Improvement Plan Reviewed"), - # improvement_plan_agreed=_TestEvent("Improvement Plan Agreed"), - ) - assert slots.initial_submitted.type_descriptor == "CAF Initial Submitted" + 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 Reviewed</td>\n" - " <td>OES Revisions Submitted</td>\n" - " <td>Validation Agreed</td>\n" - " <td>Improvement Plan Submitted</td>\n" - " <td>Improvement Plan Review</td>\n" - "</tr>\n" - ) + 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, @@ -71,17 +56,18 @@ def test_progress_chart_css_initial_review_only(caf, user): 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>OES Revisions Submitted</td>\n" - " <td>Validation Agreed</td>\n" - " <td>Improvement Plan Submitted</td>\n" - " <td>Improvement Plan Review</td>\n" - "</tr>\n" - ) + 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, @@ -97,3 +83,51 @@ def test_progress_chart_css_initial_two_events(caf, 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' + "</tr>" + ) |