Ejemplo n.º 1
0
 def generate_workflow_export(self, workflow_name, testscript, project, client, worksheet, row, column):
     
     #The number of rows in the workflow to be returned
     num_rows = 0
     
     #Find the workflow
     self.cur.execute('select wf.id, wf.name from workflow wf left join testscript ts on ts.id = wf.testscriptid) left join project p on ts.projectid = p.id) left join client c on p.clientid = c.id where wf.name = %s and ts.name = %s and p.name = %s and c.name = %s order by w.id;' % (workflow_name, testscript, project, client))
     flow = self.cur.fetchone()
     
     workflow = _Workflow()
     workflow.name = flow[1]
     workflow.id = flow[0]
     
     #Find the Key Actions for the workflow
     self.cur.execute('select ka.id, ka.name, ka.description, ka.custom, wfa.expectedresult, wfa.notes from ((workflowaction wfa left join keyaction ka on wfa.keyactionid = ka.id) left join workflow w on wfa.workflowid = w.id) where w.id = %s;' % (workflow[0]))
     keyactions = self.cur.fetchall()
     
     for action in keyactions:
         
         keyaction = _KeyAction()
         keyaction.id = action[0]
         keyaction.name = action[1]
         keyaction.description = action[2]
         if action[3] == 0:
             keyaction.custom = False
         else:
             keyaction.custom = True
         keyaction.expected_result = action[4]
         keyaction.notes = action[5]
         workflow.add_keyaction(keyaction)
         
         #Find the Input Parameters for the Key Action
         self.cur.execute('select ip.id, ip.name, wp.value from ((inputparameter ip left join keyaction ka on ip.keyactionid = ka.id) left join workflowparam wp on wp.inputparamid = ip.id) where ka.id = %s;' % (action[0]))
         inputparameters = self.cur.fetchall()
         for param in inputparameters:
             input_parameter = _InputParameter()
             input_parameter.id = param[0]
             input_parameter.name = param[1]
             input_parameter.value = param[2]
             keyaction.add_inputparameter(input_parameter)
             num_rows+=1
             
     #TODO - Write the _Workflow object to the Excel Sheet
     self.execute_workflow_export(workflow, worksheet, row, column)
         
     return num_rows
    def generate_workflow_export(self, workflow_id):
        
        #The number of rows in the workflow to be returned
        num_rows = 0
        
        #Find the workflow
        self.cur.execute("select wf.id from workflow wf where wf.id = %s" % (workflow_id))
#        self.cur.execute("select wf.id, wf.name from workflow wf left join testscript ts on ts.id = wf.testscriptid left join project p on ts.projectid = p.id left join client c on p.clientid = c.id where wf.name = '%s' and ts.name = '%s' and p.name = '%s' and c.name = '%s' order by wf.id;" % (workflow_name, testscript, project, client))
        flow = self.cur.fetchone()
        
        workflow = _Workflow()
        workflow.name = flow[1]
        workflow.id = flow[0]
        print('Workflow %s created with ID %s' % (workflow.name, workflow.id))
        
        #Find the Key Actions for the workflow
        self.cur.execute("select ka.id, ka.name, ka.description, ka.custom, wfa.expectedresult, wfa.notes from workflowaction wfa left join keyaction ka on wfa.keyactionid = ka.id left join workflow w on wfa.workflowid = w.id where w.id = '%s';" % (workflow.id))
        keyactions = self.cur.fetchall()
        
        for action in keyactions:
            
            keyaction = _KeyAction()
            keyaction.id = action[0]
            keyaction.name = action[1]
            keyaction.description = action[2]
            if action[3] == 0:
                keyaction.custom = False
            else:
                keyaction.custom = True
            keyaction.expected_result = action[4]
            keyaction.notes = action[5]
            print('Key Action %s created' % (keyaction.name))
            print('Description: %s' % (keyaction.description))
            print('Custom: %s' % (keyaction.custom))
            print('Expected Result: %s' % (keyaction.expected_result))
            
            #Find the Next Actions for the Key Action
            self.cur.execute("select ka.id, ka.name, ka.description, ka.custom, wfa.expectedresult, wfa.notes from workflowaction wfa left join keyaction ka on wfa.keyactionid = ka.id where ka.id = %s;" % (action.id))
            keyactions = self.cur.fetchall()
            for action in nextactions:
            
                ka = _KeyAction()
                ka.id = action[0]
                ka.name = action[1]
                ka.description = action[2]
                if action[3] == 0:
                    ka.custom = False
                else:
                    ka.custom = True
                ka.expected_result = action[4]
                ka.notes = action[5]
                print('Key Action %s created' % (ka.name))
                print('Description: %s' % (ka.description))
                print('Custom: %s' % (ka.custom))
                print('Expected Result: %s' % (ka.expected_result))
                keyaction.add_nextaction(ka)
            
            #Find the Input Parameters for the Key Action
            self.cur.execute('select ip.id, ip.name, wp.value from ((inputparameter ip left join keyaction ka on ip.keyactionid = ka.id) left join workflowparam wp on wp.inputparamid = ip.id) where ka.id = %s;' % (action[0]))
            inputparameters = self.cur.fetchall()
            if len(inputparameters) == 0:
                num_rows+=1
            else:
                for param in inputparameters:
                    input_parameter = _InputParameter()
                    input_parameter.id = param[0]
                    input_parameter.name = param[1]
                    input_parameter.value = param[2]
                    keyaction.add_inputparameter(input_parameter)
                    print('Input Parameter %s added to keyaction %s' % (input_parameter.name, keyaction.name))
                    num_rows+=1
            workflow.add_keyaction(keyaction)
            print('Key Action %s added to Workflow %s' % (keyaction.name, workflow.name))
                
        #Write the _Workflow object to the Excel Sheet
#        self.execute_workflow_export(workflow, worksheet, row, column)
            
        return workflow
print(tree.root.data)
for con in tree.root.connections:
    print(con.data)
    for connection in con.connections:
        print(connection.data)
        
#Key Action Tests
act = _KeyAction()
act.id=1
act2 = _KeyAction()
act2.id=2
act3 = _KeyAction()
act3.id=3

ip=_InputParameter()
ip.id=1
ip2 = _InputParameter()
ip2.id=2
ip3=_InputParameter()
ip3.id=3
ip4 = _InputParameter()
ip4.id=4
ip5=_InputParameter()
ip5.id=5
ip6 = _InputParameter()
ip6.id=6

act.add_inputparameter(ip)
print(act.numParams())