def test_columns_html_valid(self): elements = [Text("Element One"), Text("Element Two")] cell = Columns(elements) cell.recalculate() html = cell.contents self.assertHTMLNotEmpty(html) self.assertHTMLValid(html)
def serviceDisplay(serviceObject, instance=None, objType=None, queryArgs=None): if not current_transaction().db().isSubscribedToType(Happy): raise SubscribeAndRetry(lambda db: db.subscribeToType(Happy)) if instance: return instance.display(queryArgs) return Card( Subscribed(lambda: Text( "There are %s happy objects <this should not have lessthans>" % len(Happy.lookupAll()))) + Expands( Text("Closed"), Subscribed(lambda: HappyService.serviceDisplay(serviceObject))) ) + Button("go to google", "http://google.com/") + SubscribedSequence( lambda: Happy.lookupAll(), lambda h: Button( "go to the happy", serviceObject.urlForObject(h, x=10)) ) + Subscribed(lambda: ButtonGroup([ Button(Octicon("list-unordered"), lambda: None, active=lambda: True), Button(Octicon("terminal"), lambda: None, active=lambda: True), Button(Octicon("graph"), lambda: None, active=lambda: True) ]).nowrap())
def test_sequence_html_valid(self): elements = [Text("Element One"), Text("Element two")] cell = Sequence(elements) cell.recalculate() html = cell.contents self.assertHTMLNotEmpty(html) self.assertHTMLValid(html)
def serviceDisplay(serviceObject, instance=None, objType=None, queryArgs=None): c = Configuration.lookupAny(service=serviceObject) return Card(Text("Host: " + c.hostname) + Text("Port: " + str(c.port)))
def test_expands_html_valid(self): cell = Expands(Text("closed"), Text("open")) cell.cells = self.cells cell.recalculate() html = cell.contents self.assertHTMLNotEmpty(html) self.assertHTMLValid(html)
def test_popover_html_valid(self): cell = Popover(Text("This is the content"), Text("This is the title"), Text("This is the detail")) cell.cells = self.cells cell.recalculate() html = cell.contents self.assertHTMLNotEmpty(html) self.assertHTMLValid(html)
def test_cells_reusable(self): c1 = Card(Text("HI")) c2 = Card(Text("HI2")) slot = Slot(0) self.cells.withRoot(Subscribed(lambda: c1 if slot.get() else c2)) self.cells.renderMessages() slot.set(1) self.cells.renderMessages() slot.set(0) self.cells.renderMessages() self.assertFalse(self.cells.childrenWithExceptions())
def test_container_html_valid(self): child = Text("Child cell") cell = Container(child) cell.recalculate() html = cell.contents self.assertHTMLNotEmpty(html) self.assertHTMLValid(html)
def test_main_html_valid(self): child = Text("This is a child cell") cell = Main(child) cell.recalculate() html = cell.contents self.assertHTMLNotEmpty(html) self.assertHTMLValid(html)
def test_clickable_html_valid(self): cell = Clickable(Text("content"), f=lambda x: x) cell.cells = self.cells cell.recalculate() html = cell.contents self.assertHTMLNotEmpty(html) self.assertHTMLValid(html)
def test_scrollable_html_valid(self): child = Text("Child cell") cell = Scrollable(child) cell.recalculate() html = cell.contents self.assertHTMLNotEmpty(html) self.assertHTMLValid(html)
def test_subscribed_html_valid(self): child = Text("Subscribed Text") cell = Subscribed(child) # TODO: does this makes sense? cell.cells = self.cells cell.recalculate() html = cell.contents self.assertHTMLNotEmpty(html) self.assertHTMLValid(html)
def test_async_dropdown_changes(self): """Ensure that AsyncDropdown shows the loading child first, then the rendered child after changing the open state. """ changedCell = Text("Changed") def handler(): return changedCell dropdown = AsyncDropdown('Untitled', handler) dropdown.contentCell.loadingCell = Text("INITIAL") self.cells.withRoot(dropdown) self.cells.renderMessages() # Initial self.assertTrue(dropdown in self.cells) self.assertTrue(dropdown.contentCell.loadingCell in self.cells) # Changed dropdown.slot.set(True) self.cells.renderMessages() self.assertTrue(changedCell in self.cells)
def test_header_bar_html_valid(self): leftItems = [Text("Left One"), Text("Left Two")] centerItems = [Text("Center item")] rightItems = [ Text("Right One"), Text("Right Two"), Text("Right Three") ] cell = HeaderBar(leftItems, centerItems, rightItems) cell.recalculate() html = cell.contents self.assertHTMLNotEmpty(html) self.assertHTMLValid(html)
def delayAndDisplay(): time.sleep(1) return Text('NOW WE HAVE LOADED')
def any_x(X): return Text(X.x).tagged("display " + str(X.x))
def sized_x(X): return Text(X.x).tagged("sized display " + str(X.x))
def large_x(X): return Text(X.x).tagged("large display " + str(X.x))
def small_x(X): return Text(X.x).tagged("small display " + str(X.x))
def test_text_html_valid(self): cell = Text("This is some text") cell.recalculate() html = cell.contents self.assertHTMLNotEmpty(html) self.assertHTMLValid(html)
def handler(): return Text("RESULT")