diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-22 16:51:08 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-22 16:52:07 +0100 |
commit | 15073041461d2656e9612ea2c461b221c4aefd4e (patch) | |
tree | 77fc4abd695ecc13bb304591cee50c1170fbc11a | |
parent | 26ea2326bd4915e3be01bbee5c1e86a9410385e0 (diff) |
now processes a an empty event list
-rw-r--r-- | ctrack/register/css.py | 13 | ||||
-rw-r--r-- | ctrack/register/tests/test_css.py | 19 |
2 files changed, 30 insertions, 2 deletions
diff --git a/ctrack/register/css.py b/ctrack/register/css.py index 9b1f150..65a2c43 100644 --- a/ctrack/register/css.py +++ b/ctrack/register/css.py @@ -47,10 +47,19 @@ class Swimlane: ) def table_row_builder(self): + org = self.org_name if len(self.events) == 0: - raise ValueError("Cannot handle an empty list") + tmpl = "<td{0}>{1}</td>" + processing_these_attrs = [x.type_descriptor for x in self.__dict__.values() if isinstance(x, EventBase)] + empties = [{e: tmpl.format("", e)} for e in self.attrs_added if + e[:3] == "CAF" and e not in processing_these_attrs] + empties = sorted(empties, key=self._sort_func) + empties = [list(x.values())[0] for x in empties] + empties = "\n".join(empties) + return "".join( + ["<tr>\n", f"<td>{org}</td>\n", empties, "\n", "</tr>"] + ) tmpl = "<td{0}>{1}</td>" - org = self.events[0].related_caf.organisation.name processing_these_attrs = [x.type_descriptor for x in self.__dict__.values() if isinstance(x, EventBase)] empties = [{e: tmpl.format("", e)} for e in self.attrs_added if e[:3] == "CAF" and e not in processing_these_attrs] diff --git a/ctrack/register/tests/test_css.py b/ctrack/register/tests/test_css.py index fe530bd..44a681c 100644 --- a/ctrack/register/tests/test_css.py +++ b/ctrack/register/tests/test_css.py @@ -138,3 +138,22 @@ def test_table_row_builder(user, caf): "<td>CAF_VALIDATION_PERIOD</td>\n" "</tr>" ) + + +def test_table_row_builder_with_no_events(user, caf): + org_name = caf.organisation.name + sl = Swimlane(org_name, []) + assert sl.table_row_builder() == ( + "<tr>\n" + f"<td>{caf.organisation.name}</td>\n" + "<td>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>" + ) |