def handle_get(self, session_id, values, wfile): user = self.application.get_user(session_id) if user: templates.header(wfile) templates.title(wfile, "Recent changes") sort_by = values.get("sort_by", "date") order = values.get("order", "descending") changes = self.application.bugs.changes.get_recent_changes( sort_by, order) if len(changes.rows) > 0: templates.bullets( wfile, "The following table displays the last" " %d days of changes made to bugs." % config.History.changes_max_age, "This includes the addition of new bugs.", "The table is updated every hour on the hour.") templates.table_of_changes(wfile, self.path, changes) else: templates.paragraph( wfile, "There have been no changes made in the last" " %d days." % config.History.changes_max_age) templates.footer(wfile) else: values["next"] = self.path path = lib.join_url(Login.path, values) self.redirect(path)
def test_changes_table(self): """Check table of changes""" class MockRow: bug_id = "334" status = "new" titles = ["title1", "title2"] variables = ["variable1", "variable2"] sorted_by = "variable2" ordered = "descending" def get(self): return [("variable1", "value1"), ("variable2", "value2")] class MockRecentChanges: variables = "bug_id", "username", "date", "description" titles = "Bug", "User", "Date", "Description" sort_by = "date" order = "ascending" rows = [MockRow(), MockRow()] wfile = self.get_wfile() templates.table_of_changes(wfile, "a path", MockRecentChanges()) self.assert_(self.is_well_formed(wfile))