示例#1
0
    def test_command_addNote(self):
        c = Command('testNode', status='executing')
        n1 = Note('a test note')
        n2 = Note('another')
        c.addNote(n1)
        c.addNote(n2)

        self.assertEquals(len(c.notes), 2)
        self.assertEquals(c.notes[0], n1)
        self.assertEquals(c.notes[1], n2)        
示例#2
0
    def test_toElement(self):
        c = Command('testNode', status='completed', sessionid='sessionid1')

        n1 = Note('a test note')
        c.addNote(n1)

        a = Actions()
        a.setDefault('next')
        c.set_actions(a)

        form = data_form.Form(
            formType='form',
            title=u'Unregister a machine',
            instructions=[u'Please select the machine to be unregistered'],
            formNamespace=collab.COLLAB_NS
            )

        form.addField(data_form.Field(
            var = 'machine',
            label = u'Machine',
            desc = u'Please select a machine domain name',
            required = True,
            fieldType='list-multi',
            options = [data_form.Option(m) for m in ['one', 'two', 'three']]
            ))

        c.set_form(form)

        el = Element((collab.COMMAND_NS, 'command'))
        el['node'] = 'testNode'
        el['sessionid'] = 'sessionid1'
        el['status'] = 'completed'
        el.addChild(a.toElement())
        el.addChild(form.toElement())
        el.addChild(n1.toElement())

        self.assertEquals(c.toElement().toXml(), el.toXml())