예제 #1
0
def main():
    dev = devices.Device().get_devices()

    if not len(dev):
        print('there is no device connected this PC')
        return

    driver = webdriver.Remote('http://localhost:4723/wd/hub', dev[0])
    base_page = BasePage.BasePage()
    base_page.set_driver(driver)

    testunit = unittest.TestSuite()
    testunit.addTests(
        map(testcase.freestore, ["test_login_logout", "test_mian"]))
    # testunit.addTest(testcase.freestore("test_mian"))
    # test_suit.addTests(map(Mydemo, ["Mytest1", "Mytest2", "Mytest3"]))
    now = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time()))
    HtmlFile = "D:\\test\\" + now + "HTMLtemplate.html"
    fp = open(HtmlFile, "wb")
    runner = HTMLTestRunner.HTMLTestRunner(stream=fp,
                                           title=u"测试报告",
                                           description=u"用例测试情况")
    runner.run(testunit)

    fp.close()
 def operation(self, ip, community, version):
     temp_walk = devices.Device()
     self.result_desc = temp_walk.walkthrongh(ip, self.IFDESCR)
     self.result_Type = temp_walk.walkthrongh(ip, self.IFTYPE)
     self.result_Speed = temp_walk.walkthrongh(ip, self.IFSPEED)
     self.result_Admin = temp_walk.walkthrongh(ip, self.IFADMINSTATUS)
     self.result_Opera = temp_walk.walkthrongh(ip, self.IFOPERSTATUS)
예제 #3
0
 def parse(fromNumber,endpoint,callState,connectedNumber,direction,channelid,secondchannelid):
     number,state,connected = (None,None,None)
     number = parseEndpoint(endpoint)
     if number is None and fromNumber is not None:
         number = fromNumber
     
     connected = connectedNumber
     state = callState
         
     if connected == "":
         for device in deviceContainer.container.values():
             if number == device.getConnected():
                 connected = device.getNumber()
     
     if number and state and connected:
         if number in deviceContainer.container:
             direction = deviceContainer.container[number].getDirection()
         buf_device = devices.Device(number,state,connected,direction,channelid,secondchannelid)
         buf_device.setPrimary(connected)
         deviceContainer.putDevice(buf_device)
예제 #4
0
    def run_driver(self):
        device = devices.Device().get_devices()
        port = Ports.Ports().get_ports(len(device))

        if not len(device):
            print('测试设备未连接!')
            return

        runs = []
        for i in range(len(device)):
            runs.append(runcase.RunCase(device[i], port[i]))

        Appium_server = AppiumServer.AppiumServer(runs)
        Appium_server.start_server()
        print('good')

        pool = Pool(processes=len(runs))
        for run in runs:
            print('hello')
            pool.apply_async(self._run_cases, args=(run, ))
        pool.close()
        pool.join()
예제 #5
0
def generate(): 
	"""
	Generates all system device instances based on user input. 
	Returns list of all system devices.

	"""

	print io.sys_mode("System Setup")

	# Dictionary of type of devices and how many devices of each type
	system_device_types = {}

	print "For each device type, please specify the number of devices."

	for d in valid_device_types: 	
		# Add device type & how many of each type 
		system_device_types[d] = None
		system_device_types[d] = io.get_valid_int(d)

	print io.sys_mode("Initialize Disk Drive",'-')

    # List of all individual devices in system
	system_devices = []

	for dev_type, num_of_dev in system_device_types.iteritems(): 
		name_prefix = dev_type[0].lower()

		# Create new device, add to list of system_devices
		for i in range(num_of_dev):
			name = name_prefix + str(i+1)

			if (dev_type == "Disk Drive"):
				cyl = io.get_valid_int("Num of cylinders for " + name)
				system_devices.append(devices.DiskDrive(name,cyl))
			else:
				system_devices.append(devices.Device(name, dev_type))

	return system_devices
	
예제 #6
0
# -*- coding: utf-8 -*-
from appium import webdriver
import time
import xlrd
import Decorator
import devices
import unittest
from HTMLTestRunner import HTMLTestRunner

# def decorator(func):
#    def wrapper(*args, **kwargs):
#        print('i am log')
#        return func(*args, **kwargs)
#    return wrapper

device = devices.Device()
desired_caps = device.get_devices()
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps[0])


def execl_rows(sheet):
    workbook = xlrd.open_workbook(r'D:\test\account.xlsx')
    index = workbook.sheet_by_index(sheet)
    rows = index.nrows
    return rows


def read_excel(rowx, colx):
    workbook = xlrd.open_workbook(r'D:\test\account.xlsx')
    index = workbook.sheet_by_index(0)
    value = index.cell_value(rowx, colx)
예제 #7
0
def store_device(unique_id, description):
    session.add(
        devices.Device(device_id=unique_id, device_description=description))
    session.commit()