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 testBlipRefValue(self): blip = self.new_blip(blipId=ROOT_BLIP_ID) content = blip.text content = content[:4] + content[5:] del blip[4] self.assertEquals(content, blip.text) content = content[:2] + content[3:] del blip[2:3] self.assertEquals(content, blip.text) blip[2:3] = 'bike' content = content[:2] + 'bike' + content[3:] self.assertEquals(content, blip.text) url = 'http://www.test.com/image.png' blip.append(element.Image(url=url)) self.assertEqual(url, blip.first(element.Image).url) url2 = 'http://www.test.com/another.png' blip[-1].update_element({'url': url2}) self.assertEqual(url2, blip.first(element.Image).url) self.assertTrue(blip[3:5] == blip.text[3:5]) blip.append('geheim') self.assertTrue(blip.first('geheim')) self.assertFalse(blip.first(element.Button)) blip.append(element.Button(name='test1', value='Click')) button = blip.first(element.Button) button.update_element({'name': 'test2'}) self.assertEqual('test2', button.name)