def testCanInstantiate(self): bag = [ element.Check(name='check', value='value'), element.Button(name='button', value='caption'), element.Input(name='input', value='caption'), element.Label(label_for='button', caption='caption'), element.RadioButton(name='name', group='group'), element.RadioButtonGroup(name='name', value='value'), element.Password(name='name', value='geheim'), element.TextArea(name='name', value='\n\n\n'), element.Installer(manifest='test.com/installer.xml'), element.Line(line_type='type', indent='3', alignment='r', direction='d'), element.Gadget(url='test.com/gadget.xml', props={ 'key1': 'val1', 'key2': 'val2' }), element.Image(url='test.com/image.png', width=100, height=200), element.Attachment(caption='fake caption', data='fake data') ] types_constructed = set([type(x) for x in bag]) types_required = set(element.ALL.values()) missing_required = types_constructed.difference(types_required) self.assertEquals(missing_required, set()) missing_constructed = types_required.difference(types_constructed) self.assertEquals(missing_constructed, set())
def testSerializeGadget(self): gadget = element.Gadget('http://test.com', { 'prop1': 'a', 'prop_cap': None }) s = util.serialize(gadget) k = s.keys() k.sort() # we should really only have three things to serialize props = s['properties'] self.assertEquals(len(props), 3) self.assertEquals(props['url'], 'http://test.com') self.assertEquals(props['prop1'], 'a') self.assertEquals(props['prop_cap'], None)
def testSerialize(self): self.blip.append(element.Gadget('http://test.com', {'a': 3})) self.wavelet.title = 'A wavelet title' self.blip.append( element.Image(url='http://www.google.com/logos/clickortreat1.gif', width=320, height=118)) self.blip.append(element.Attachment(caption='fake', data='fake data')) self.blip.append(element.Line(line_type='li', indent='2')) self.blip.append('bulleted!') self.blip.append( element.Installer( 'http://wave-skynet.appspot.com/public/extensions/areyouin/manifest.xml' )) self.wavelet.proxy_for('proxy').reply().append('hi from douwe') inlineBlip = self.blip.insert_inline_blip(5) inlineBlip.append('hello again!') serialized = self.wavelet.serialize() serialized = simplejson.dumps(serialized) self.assertTrue(serialized.find('test.com') > 0)
def testGadget(self): gadget = element.Gadget('http://test.com/gadget.xml') self.assertEquals(element.Gadget.class_type, gadget.type) self.assertEquals(gadget.url, 'http://test.com/gadget.xml')