def test_query_store(self, url, method, test_data, resp_code,
                         resp_content):
        print('url', url)
        query_store_count = len(self.store_query.query_store(url, test_data))

        # 查询0库存
        sql_zero = 'SELECT COUNT(*) FROM storesum WHERE  remained = 0'
        zero_count = Utility.query_one('../config/base.conf', sql_zero)[0]

        # 查询未入库
        sql_no_store = 'SELECT COUNT(*) FROM goods WHERE barcode="0"'
        nostore_count = Utility.query_one('../config/base.conf',
                                          sql_no_store)[0]

        # 根据货号查询库存
        sql_condition_store = 'SELECT COUNT(*) FROM storesum WHERE goodsserial="M4T2047C"'
        condition_store_count = Utility.query_one('../config/base.conf',
                                                  sql_condition_store)[0]

        if query_store_count == zero_count:
            actual = 'query_success'
        elif query_store_count == nostore_count:
            actual = 'query_success'
        elif query_store_count == condition_store_count:
            actual = 'query_success'
        else:
            actual = 'query error'
        self.assertEqual(actual, resp_content)
Exemplo n.º 2
0
    def test_query_customer(self):
        query_customer_info = Utility.get_excel_to_dict(
            self.data_config_info[2])
        for query_info in query_customer_info:
            query_customer_url = query_info['URL']
            query_customer_data = query_info['DATA']
            query_customer_content = self.customer.query_customer(
                query_customer_url, query_customer_data)
            sql_all = 'select count(customerid) from customer'
            all_customer_number = Utility.query_one('..\\config\\base.conf',
                                                    sql_all)[0]
            phone = query_customer_data['customerphone']
            # sql_part = 'select count(customerid) from customer where customerphone like "%'+phone+'%"'
            sql_part = 'select count(customerid) from customer where customerphone like "%s"' % (
                phone)
            part_cusomer_number = Utility.query_one('..\\config\\base.conf',
                                                    sql_part)[0]
            if len(query_customer_content) == 0:
                actual = 'query zero'
            elif len(query_customer_content) == 1:
                actual = 'query one'
            elif len(query_customer_content) == all_customer_number:
                actual = 'query all'
            elif len(query_customer_content) == part_cusomer_number:
                actual = 'query part'
            else:
                actual = 'query error'

            flag = Utility.assert_equals(actual, query_info['CONTENT'])
            if flag:
                print('query customer test pass')
            else:
                print('query customer test fail')
Exemplo n.º 3
0
    def test_add_customer(self):
        add_customer_info = Utility.get_excel_to_dict(self.data_config_info[1])
        for add_info in add_customer_info:
            add_customer_url = add_info['URL']
            add_customer_data = add_info['DATA']

            add_customer_resp = self.customer.add_customer(
                add_customer_url, add_customer_data)

            # 断言
            flag = Utility.assert_equals(add_customer_resp.text,
                                         add_info['CONTENT'])
            if flag:
                print('add customer test pass')
            else:
                print('add customer test fail')
Exemplo n.º 4
0
 def query_batch(self, url, method, data, resp_code, resp_content):
     resp = self.batch_manage.query_batch(url, data, filePath)
     sql = "SELECT COUNT(*) FROM goods WHERE batchname={}".format(
         data['batchname'])
     sql_result = Utility.query_one('../config/base.conf', sql)
     if len(resp.json()) == sql_result:
         actual = 'query_success'
     self.assertEqual(actual, resp_content)
	def test_query_customer(self,url,method,test_data,resp_code,resp_content):
		query_customer_content = self.customer.query_customer(url, test_data)
		sql_all = 'select count(customerid) from customer'
		all_customer_number = Utility.query_one('../config/base.conf', sql_all)[0]
		phone = test_data['customerphone']
		sql_part = 'select count(customerid) from customer where customerphone like "%s"' % (phone)
		part_cusomer_number = Utility.query_one('../config/base.conf', sql_part)[0]
		if len(query_customer_content) == 0:
			actual = 'query zero'
		elif len(query_customer_content) == 1:
			actual = 'query one'
		elif len(query_customer_content) == all_customer_number:
			actual = 'query all'
		elif len(query_customer_content) == part_cusomer_number :
			actual = 'query part'
		else:
			actual = 'query error'
		self.assertEqual(actual, resp_content)
Exemplo n.º 6
0
    def test_login(self):
        # 准备数据
        login_info = Utility.get_excel_to_dict(self.data_config_info[0])
        for info in login_info:
            login_url = info['URL']
            login_data = info['DATA']
            from interfacetest.woniusales_test01.common.login import Login
            login_resp = Login().do_login(login_url, login_data)
            # 获取响应码和响应正文
            # login_resp_code = login_resp.status_code
            #将返回的正文当做预期结果
            login_resp_content = login_resp.text

            # 断言
            flag = Utility.assert_equals(login_resp_content, info['CONTENT'])
            if flag:
                print('login test pass')
            else:
                print('login test fail')
Exemplo n.º 7
0
 def get_session(cls):
     base_info = Utility.get_json('..\\config\\base.conf')
     login_url = "%s://%s:%s/%s/" % (base_info['PROTOCOL'],
                                     base_info['HOSTNAME'],
                                     base_info['PORT'], base_info['AURL'])
     login_data = {
         "username": base_info["USERNAME"],
         "password": base_info["PASSWORD"],
         "verifycode": base_info["VERIFYCODE"]
     }
     session = requests.session()
     session.post(login_url, login_data)
     return session
Exemplo n.º 8
0
from interfacetest.woniusales_test01.common.sales_report import SalesReports
from interfacetest.woniusales_test01.util.utility import Utility
import unittest
from parameterized import parameterized
data_config_path = '../config/testdata.conf'

data_config_info = Utility.get_json(data_config_path)
result_info = Utility.get_excel_to_tuple(data_config_info[7])


class SaleReportTest(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.sale_report = SalesReports()

    @parameterized.expand(result_info)
    def test_sale_report_selldetailtoday(self, url, method, data, resp_code,
                                         resp_content):
        resp = self.sale_report.query_selldetailtoday(url, data)
        self.assertEqual(resp.text, resp_content)


if __name__ == '__main__':
    unittest.main(verbosity=2)
Exemplo n.º 9
0
    def __init__(self, data_config_path):

        self.data_config_info = Utility.get_json(data_config_path)
import requests

from interfacetest.woniusales_test01.common.customer import Customer
from interfacetest.woniusales_test01.util.utility import Utility
import unittest
from parameterized import parameterized

base_conf_path = '../config/base.conf'
data_config_info = Utility.get_json('../config/testdata.conf')

add_customer_info = Utility.get_excel_to_tuple(data_config_info[1])
query_customer_info = Utility.get_excel_to_tuple(data_config_info[2])
edit_customer_info = Utility.get_excel_to_tuple(data_config_info[3])
class CustomerTest(unittest.TestCase):

	@classmethod
	def setUpClass(cls):
		cls.customer = Customer()

	# 添加会员
	@parameterized.expand(add_customer_info)
	def test_add_customer(self,url,method,test_data,resp_code,resp_content):
		print(url)
		add_customer_resp = self.customer.add_customer(url,test_data)
		self.assertEqual(add_customer_resp.text,resp_content)



	# 会员查询  查询1条 查询0条 查询所有 查询部分
	@parameterized.expand(query_customer_info)
	def test_query_customer(self,url,method,test_data,resp_code,resp_content):
Exemplo n.º 11
0
 def __init__(self, data_config_path):
     self.customer = Customer()
     self.data_config_info = Utility.get_json(data_config_path)
import requests, json

from interfacetest.woniusales_test01.common.customer import Customer
from interfacetest.woniusales_test01.common.sales import Sales
from interfacetest.woniusales_test01.util.utility import Utility
import unittest
from parameterized import parameterized
base_conf_path = '../config/base.conf'
data_config_path = '../config/testdata.conf'

data_config_info = Utility.get_json(data_config_path)

scan_barcode_info = Utility.get_excel_to_tuple(data_config_info[11])

query_customer_info = Utility.get_excel_to_tuple(data_config_info[5])


class SalesTest(unittest.TestCase):

    # 商品扫码
    @parameterized.expand(scan_barcode_info)
    def test_scan_barcode(self, url, method, test_data, resp_code,
                          resp_content):
        resp = Sales().scan_barcode(url, test_data)
        self.assertEqual(resp.text, resp_content)

    # 会员信息查询
    @parameterized.expand(query_customer_info)
    def test_query_customer(self, url, method, test_data, resp_code,
                            resp_content):
        resp = Sales().query_customer(url, test_data)
Exemplo n.º 13
0
import requests, time
import unittest
from parameterized import parameterized

from interfacetest.woniusales_test01.common.goods_store import GoodsStore
from interfacetest.woniusales_test01.util.utility import Utility

data_config_path = '../config/testdata.conf'

data_config_info = Utility.get_json(data_config_path)
info = Utility.get_excel_to_tuple(data_config_info[10])


class GoodsStoreTest(unittest.TestCase):
    @parameterized.expand(info)
    def test_goods_store(self, url, method, test_data, resp_code,
                         resp_content):
        resp = GoodsStore().goods_store(url, test_data)
        if len(resp.json()) > 0:
            actual = 'store_success'

        self.assertEqual(actual, resp_content)


if __name__ == '__main__':
    unittest.main(verbosity=2)
import requests

from interfacetest.woniusales_test01.common.customer import Customer
from interfacetest.woniusales_test01.common.store_query import StoreQuery
from interfacetest.woniusales_test01.util.utility import Utility
import unittest
from parameterized import parameterized

base_conf_path = '../config/base.conf'
data_config_info = Utility.get_json('../config/testdata.conf')
query_info = Utility.get_excel_to_tuple(data_config_info[9])


class StoreQueryTest(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.store_query = StoreQuery()

    @parameterized.expand(query_info)
    def test_query_store(self, url, method, test_data, resp_code,
                         resp_content):
        print('url', url)
        query_store_count = len(self.store_query.query_store(url, test_data))

        # 查询0库存
        sql_zero = 'SELECT COUNT(*) FROM storesum WHERE  remained = 0'
        zero_count = Utility.query_one('../config/base.conf', sql_zero)[0]

        # 查询未入库
        sql_no_store = 'SELECT COUNT(*) FROM goods WHERE barcode="0"'
        nostore_count = Utility.query_one('../config/base.conf',