Welcome To Our Shell

Mister Spy & Souheyl Bypass Shell

Current Path : /home/ift/52_procpy/dataninja/test/

Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
Upload File :
Current File : //home/ift/52_procpy/dataninja/test/test2.py

#  coding: utf8

import os,re,sys,time
import procpy
import random
from . import autotest_logging

class Test2 (object):
    
    def __init__ (self,api):
    
        self.api = api                                         

    def run (self):
        file = "testlog_test2.txt"
        req = []
        testlog = []

        req1,log1  = self.test_create_block()
        req.append(req1)
        testlog.append(log1)

        req2,log2 = self.test_create_swimlane()
        req.append(req2)
        testlog.append(log2)

#       req,testlog =  self.test_rearrange()

        req3,log3 = self.test_save_and_open()
        req.append(req3)
        testlog.append(log3)

####### Ausgabe muss noch ueberarbeitet werden
        for i in range(0,len(req)):
            print(req[i], testlog[i])
        #   open(file,"a").write(req[i], testlog[i])

#***************************************** Test Cases *********************************************************
    def test_create_block(self):

        printmessage = [0, 0, 0, 1] # test not passed
        req = "BLOCK-11-VALID"
        try:

            self.tab = self.api.gui.fileopen('test1.py')
            nbr_of_block = 4
        
            for i in range(nbr_of_block):
                dx = (random.randint(1, nbr_of_block))
                dy = (random.randint(1, nbr_of_block))
                self.api.next(2, self.create_block(self.tab, [100*dx, 100*dy, 70, 40]))
            if len(self.tab.blocks) == nbr_of_block:
                 printmessage = [1, 0, 0, 0] # test OK
            else:
                 printmessage = [0, 1, 0, 0] # test not OK
        except Exception as e:
            print(str(e))

        
        return req, printmessage
#***************************************** Test Cases *********************************************************

    def test_create_swimlane(self):

        printmessage = [0, 0, 0, 1] # test not passed
        req = "SWIM-11-VALID"
        
        try:
         
            self.tab = self.api.gui.fileopen('test.py')
            self.api.next(2, self.create_block(self.tab, [-5, 20, 70, 40]))

            swimlane = self.tab.blocks[-1]
            if swimlane.shape == 'a':
                 printmessage = [1, 0, 0, 0] # test OK
            else:
                 printmessage = [0, 1, 0, 0] # test not OK

        except Exception as e:
            print(str(e))

        return req, printmessage
#************************************************Test Cases*******************************************
    def test_save_and_open(self):

        printmessage = [0, 0, 0, 1] # test not passed
        req = "SAVE-001-VALID"
       
        try:

            self.build_graph('test.py',2,[[0,1]])
            self.save_graph()
            self.open_graph('test.py')
            
            if len(self.tab.blocks)==2:
                 printmessage = [1, 0, 0, 0] # test OK
            else:
                 printmessage = [0, 1, 0, 0] # test not OK

        except Exception as e:
            print(str(e))

        return req, printmessage

#************************************************UTILITIY FUNCTIONS (UF)*******************************************  
    
    #********************************UF: open_graph DONE*****************************************
    
    def open_graph (self, path):
        print('opening graph ...')
        return self.api.gui.fileopen	(path)
    
    #********************************UF: create_block DONE*****************************************
    def create_block (self, tab, block=[0,0,0,0]):  
        tab.create_block(block)
        
    #********************************UF: connect_blocks DONE*****************************************
    # Connects the given blocks pairs drawn inside the given tab together.
    #e.g.: self.connect_blocks (self.tab, [[0,1]]) 
    def connect_blocks (self, tab, connectors=[]):
        for i in range(len(connectors)):
            self.api.next(2, self.click_once(self.tab.blocks[connectors[i][0]]))
            self.api.next(2, self.click_twice(self.tab.blocks[connectors[i][1]]))
            
    #********************************UF: build_graph DONE*****************************************
    #Build a graph with the given numbers of blocks and connectors.
    #e.g.: self.build_graph ('graph.py', 2, [[0,1]]) 
    def build_graph (self, path, nbr_of_block, connectors=[]):
        self.tab = self.open_graph(path)
        print('building graph...')
        for i in range(nbr_of_block):
            dx = (random.randint(1, nbr_of_block))
            dy = (random.randint(1, nbr_of_block))
            self.api.next(2, self.create_block(self.tab, [100*dx, 100*dy, 70, 40]))
        self.api.next(2, self.connect_blocks (self.tab, connectors))
        #self.api.next(10, self.save_graph)
        print('graph built.')
    
    #********************************UF: show_grid WIP*****************************************
    def show_grid(self):
        print('Showing the grid ...')
        self.api.next(2, self.api.gui.loopobj.app.event_generate('<Control-r>'))
        
    #********************************UF: save_graph WIP*****************************************
    def save_graph (self):
        print('saving ...')
        self.api.gui.filesave
        print('saved.')
        
        
    #********************************UF: click_once DONE****************************************
    def click_once (self, block):     
        if 'content' in vars(block):
            block.content.event_generate("<Button-1>",x=100, y=100)
            block.content.event_generate("<ButtonRelease-1>",x=100, y=100)
            
    #****************************UF: click_twice DONE********************************************
   
    def click_twice (self, block):
        if 'content' in vars(block):
                block.content.event_generate("<Button-1>",x=100, y=100)
                block.content.event_generate("<ButtonRelease-1>",x=100, y=100)
                block.content.event_generate("<B1-Motion>",x=100, y=100)
                block.content.event_generate("<Button-1>",x=100, y=100)
                block.content.event_generate("<ButtonRelease-1>",x=100, y=100)
                
    #****************************UF: rearr_graph DONE********************************************
    def rearr_graph (self):
        print('rearranging the graph ...')
        self.api.next(3, self.api.gui.loopobj.app.event_generate('<Control-d>'))
        
     #****************************UF: rearr_sugiyama DONE********************************************
    def rearr_sugiyama (self):
        print('rearranging the graph ...')
        self.api.next(3, self.api.gui.loopobj.app.event_generate('<Control-q>'))
        
    #****************************UF: rearr_circle DONE********************************************
    
    def rearr_circle (self):
        print('rearranging the graph ...')
        self.api.next(3, self.api.gui.loopobj.app.event_generate('<Control-i>'))
        
    #****************************UF: rearr_swimlane DONE********************************************
    def rearr_swimlane (self):
        print('rearranging the graph ...')
        self.api.next(3, self.api.gui.loopobj.app.event_generate('<Control-e>'))     

#*************************prod2 20160822****************************************************

bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped)
Email: contact@elmoujehidin.net bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped) Email: contact@elmoujehidin.net