Ejemplo n.º 1
0
    def test_update_resource(self):
        proc = ElementFormProcessor.create(self.sess)

        form = self.read_form("multi")
        proc.create_all(form)

        form = self.read_form("update_resource")
        proc.update_all(form)

        p = self.sess.find_element("Person/eddie")
        assert p is not None, "could not find Person/eddie"
Ejemplo n.º 2
0
    def test_multi_form(self):
        proc = ElementFormProcessor.create(self.sess)
        form = self.read_form("multi")
        proc.create_all(form)

        p = self.sess.find_element("Person/eddie")
        assert p is not None, "could not find Person/eddie"
        eq_(p.age, 12)

        a = self.sess.find_element("Address/ADDR-eddie-Work")
        eq_(a.person, p)
Ejemplo n.º 3
0
    def test_dump_form(self):
        proc = ElementFormProcessor.create(self.sess, show_read_only=False)

        form = self.read_form("multi")
        proc.create_all(form)

        p = self.sess.find_element("Person/eddie")

        actual_form = proc.to_form(p)

        expected_form = self.read_form("dump")

        self.compare_data(expected_form, actual_form)
Ejemplo n.º 4
0
Archivo: show.py Proyecto: nveeser/dino
    def execute(self, session):
    
        specs = [ ObjectSpec.parse(arg) for arg in self.args ]
            
        spec_types = set([ type(spec) for spec in specs ])
            
        # make sure all the ObjectSpecs are of the same type. 
        if len(spec_types) > 1:
            self.log.error("Cannot mix ObjectSpec types in single command: %s" % spec_types)
            raise CommandArgumentError(self, "More than two types specified: " )
        
        object_spec_type = spec_types.pop() 
        
        # Use the specific ObjectSpec class to properly 
        # find the results of the each ObjectSpec      
        result = list(self.resolve_all_specs(session, specs))

        
        # EntityName
        if object_spec_type is EntityName:
            display_proc = result[0].entity_display_processor()
            result = display_proc.show(result[0])


        # ElementQuery, EntityQuery - Optionally dump as a set of forms
        if object_spec_type in (EntityQuery, ElementQuery) and self.option.form_output:                        
            processor = ElementFormProcessor.create(session, show_headers=False)                            
            result = processor.to_form(result)
                
        
        # ElementName - display using Element Specific method
        if object_spec_type is ElementName:
            assert len(result) == 1 and isinstance(result[0], Element), "ElementName type failure"
            display_proc = result[0].display_processor()            
            result = display_proc.show(result[0])

                 
        if object_spec_type in (AttributeName,):
            result = list(self._format_attribute(result))

        if not self.cli:
            return result
        
        if isinstance(result, basestring):
            print result
            
        elif isinstance(result, (list, tuple, types.GeneratorType)):            
            for x in result:
                print str(x)
        else:
            raise RuntimeError("spec types returned invalid result: %s" % type(result))
Ejemplo n.º 5
0
    def test_create_form(self):
        proc = ElementFormProcessor.create(self.sess)

        form = self.read_form("person")
        proc.create_all(form)

        p = self.sess.find_element("Person/eddie")
        assert p is not None, "could not find Person/eddie"
        eq_(p.age, 12)

        ##################

        form = self.read_form("address")
        proc.create_all(form)

        a = self.sess.find_element("Address/ADDR-eddie-Work")
        eq_(a.person, p)

        ##################

        form = self.read_form("person_update")
        proc.update_all(form)
        eq_(len(p.addresses), 0)