def test_status(self): obj = GlanceUpdate( lozenge_type=LOZENGE_DEFAULT, lozenge_value="foo", ) status = obj.status() self.assertEqual(status['type'], 'lozenge') self.assertEqual( status['value'], { 'type': LOZENGE_DEFAULT, 'label': "foo" } ) # now try with an icon obj.lozenge_type = LOZENGE_EMPTY obj.icon_url = "www" obj.icon_url2 = "xyz" self.assertEqual(obj.status()['type'], 'icon') self.assertEqual( obj.status()['value'], { 'url': "www", 'url@2x': "xyz" } ) obj.icon_url = '' self.assertEqual(obj.status(), {})
def test_metadata(self): obj = GlanceUpdate( lozenge_type=LOZENGE_DEFAULT, lozenge_value="foo", ) self.assertEqual( obj.content(), { 'status': obj.status(), 'label': obj.label() } ) obj.metadata = {'foo': 'bar'} self.assertEqual(obj.content()['metadata'], {'foo': 'bar'})