Example #1
0
 def __init__(self):
     self.conn = pymysql.connect(util.get_config_value('db', 'host'),
                                 util.get_config_value('db', 'user'),
                                 util.get_config_value('db', 'pass'),
                                 util.get_config_value('db', 'dbname'),
                                 charset='utf8')
     self.cursor = self.conn.cursor(cursor=SSDictCursor)
Example #2
0
 def test_edit_customer(self):
     rand_phone = random.randrange(10000000, 99999999)
     data = Utility.build_dict(
         'customerid=1&customerphone=18%d&customername='
         '某人&childsex=男&childdate=2015-12-31'
         '&creditkids=500&creditcloth=516750' % rand_phone)
     resp = Utility.get_session().\
         post('http://127.0.0.1:8080/WoniuSales-20180508-V1.4-bin/customer/edit',data)
     self.write_result('修改会员', 'edit-successful', resp.text)
Example #3
0
 def test_login_gui(self):
     login_list = self.read_login_data()
     for login in login_list:
         self.login_object.do_login(login['username'], login['password'])
         try:
             self.login_object.driver.find_element_by_link_text('注销')
             # print('登录成功')
             util.assert_result_2('登录模块', 'GUI', '测试基本登录功能', '成功')
         except:
             util.assert_result_2('登录模块', 'GUI', '测试基本登录功能', '失败')
Example #4
0
 def test_login_http(self):
     login = self.read_login_data()[0]
     data = {
         'username': login['username'],
         'password': login['password'],
         'verifycode': '0000'
     }
     resp = util.get_session().post(
         'http://127.0.0.1:8080/WoniuSales-20180508-V1.4-bin/user/login',
         data)
     util.assert_result('登录测试', '接口测试', '基本登录功能测试', 'login-pass', resp.text)
Example #5
0
 def test_sell(self):
     # 从csv文件中随机读取一个条码
     barcode_list = self.read_sell_barcode()
     barcode = random.choice(barcode_list)
     self.sell_object.do_buy_goods(barcode, '78')
     # 从数据库中随机读取一个电话号码
     phone = self.database.querry_one(
         'SELECT customerphone FROM customer ORDER BY RAND() LIMIT 0,1')
     self.sell_object.do_sell(phone['customerphone'], '1.8')
     #销售完后进行断言,直接从数据库中取值
     sql = "SELECT barcode FROM sell WHERE barcode = '{}' ORDER BY sellid DESC LIMIT 0,1".format(
         barcode)
     if self.database.querry_one(sql) is None:
         Utility.assert_result_2('销售出库模块', 'GUI测试', '扫码功能测试', '失败')
     else:
         Utility.assert_result_2('销售出库模块', 'GUI测试', '扫码功能测试', '成功')
Example #6
0
 def report(self):
     # 先对result目录进行压缩
     os.system(r'"%s" a %s\report.rar %s' % (Utility.get_config_value(
         'ci', 'rar'), self.ci_folder, self.result_folder))
     time.sleep(5)
     # 获取report目录下的html报告名
     list = os.listdir(self.result_folder)
     for item in list:
         if re.match('\\d+_\\d+\\.html', item):
             report_name = item
             break
     with open(self.result_folder + './' + report_name,
               encoding='utf-8') as file:
         body = file.read()
     self.email(body, '%s\\report.rar' % self.ci_folder)
Example #7
0
 def test_add_customer(self):
     list = self.read_customer_data()
     for item in list:
         data = {
             'customername': item['customername'],
             'customerphone': item['customerphone'],
             'childsex': item['childsex'],
             'childdate': item['childdate'],
             'creditkids': item['creditkids'],
             'creditcloth': item['creditcloth']
         }
         resp = Utility.get_session().post(
             'http://127.0.0.1:8080/WoniuSales-20180508-V1.4-bin/customer/add',
             data=data)
         # print('test_add_customer 参数',data)
         self.write_result('新增会员', item['expectresult'], resp.text)
Example #8
0
    def start_test(self):
        # login_test = LoginTest()
        # login_test.test_login_gui()
        # login_test.test_login_http()
        #
        # SellTest().test_sell()
        # customer_test = CustomerTest()
        # customer_test.test_add_customer()
        # customer_test.test_edit_customer()

        # 在不同的模块的case里边实现高内聚,在suit层调用模块级用例实现低耦合
        Utility.version = Utility.get_config_value('ci','version')
        LoginTest().main_test()
        SellTest().main_test()
        CustomerTest().main_test()
        Reporter().generate_report(Utility.version)
Example #9
0
 def __init__(self):
     self.driver = Utility.get_webdriver()
Example #10
0
 def __init__(self):
     self.svn_folder = Utility.get_config_value('ci', 'svn')
     self.svn_url = Utility.get_config_value('ci', 'svn_url')
     self.tomact_folder = Utility.get_config_value('ci', 'tomcat')
     self.result_folder = os.path.abspath('../result')
     self.ci_folder = os.path.abspath('.')