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_has_lozenge(self): obj = GlanceUpdate(glance=self.glance) self.assertEqual(obj.lozenge_type, LOZENGE_EMPTY) self.assertFalse(obj.has_lozenge) for choice in GlanceUpdate.LOZENGE_CHOICES: obj.lozenge_type = choice self.assertEqual(obj.has_lozenge, choice != LOZENGE_EMPTY)