diff --git a/TestCase/setting/test_07_shopifyIntegration.py b/TestCase/setting/test_07_shopifyIntegration.py new file mode 100644 index 0000000000000000000000000000000000000000..d71be3437c62f59f562aa365b9e5d9b1fe39e3b4 --- /dev/null +++ b/TestCase/setting/test_07_shopifyIntegration.py @@ -0,0 +1,13 @@ +import pytest +from Utils import yaml_handler +from Utils import req_handler +from TestData.setting.shopify_integration_test_data import shopifyIntegrationData + +class TestShopifyIntegration: + + yaml_path = r'setting/shopifyIntegration.yaml' + yaml_data = yaml_handler.yaml_handler.get_case(yaml_path) + @pytest.mark.flaky(reruns=shopifyIntegrationData.rerun, reruns_delay=shopifyIntegrationData.rerun_delay) + @pytest.mark.parametrize('case',yaml_data) + def test_shopifyIntegration(self,case): + req_handler.ReqHandler.send_requests(case=case,var_class=shopifyIntegrationData) diff --git a/TestData/setting/shopify_integration_test_data.py b/TestData/setting/shopify_integration_test_data.py new file mode 100644 index 0000000000000000000000000000000000000000..8179d15206ac4c86cce5640ef36d8b564a941185 --- /dev/null +++ b/TestData/setting/shopify_integration_test_data.py @@ -0,0 +1,22 @@ +from Utils.global_variate import Global + +class shopifyIntegrationData(Global): + brandId = 6052 + companyId = 6059 + append_shop_name = 'autotest' + update_shop_name = 'update_autotest_shop_name' + append_shop_url = 'autotest.shopify.com' + append_third_id = '510588288139012978' + append_shop_js = '' + append_faq_willdesk_domain = 'cojnpvo6nc921eeo4fc0.willdesk.net' + append_faq_cname_domain = None + append_integrated_email = '' + append_shop_email = '' + append_shop_currency = '' + append_shop_connect_status = 1 + shop_source = 2 + js_soucrce = 1 + active_shop_email = 'zhanhuasheng@channelwill.cn' + new_workspance_name = 'autotest_workspace' + + diff --git a/TestFile/setting/shopifyIntegration/shopifyIntegration_shop_select.py b/TestFile/setting/shopifyIntegration/shopifyIntegration_shop_select.py new file mode 100644 index 0000000000000000000000000000000000000000..88bfe4a93a26c827a8dcd7f209b8c51be878f38a --- /dev/null +++ b/TestFile/setting/shopifyIntegration/shopifyIntegration_shop_select.py @@ -0,0 +1,77 @@ +from Utils.sql_handler import test_env_conn +from TestData.setting.shopify_integration_test_data import shopifyIntegrationData +shopify_shop_select_sql = f'select * from `shop` where brand_id = {shopifyIntegrationData.brandId} and source in (1,2) and is_delete in (0,2)' +shopify_shop_select_result = test_env_conn.select_many_value(sql=shopify_shop_select_sql) +shopify_shop_insert_sql = f"""INSERT INTO willdesk.shop (company_id,brand_id,`source`,shop_name,website_name,shop_domain,shop_url,shop_owner,phone,email,install_email,third_id,third_token,third_plan,money_format,time_zone,country,country_code,currency,province,city,address,zip,is_review,reviews,`language`,connect_status,shop_js,integrated_email,theme_id,theme_ext_version,faq_willdesk_doamin,faq_cname_domain,embedding_switch,embedding_check_time,is_delete,uninstall_time,create_at,update_at,integration_rdc) VALUES + ({shopifyIntegrationData.companyId},{shopifyIntegrationData.brandId},{shopifyIntegrationData.shop_source},'{shopifyIntegrationData.append_shop_name}','','{shopifyIntegrationData.append_shop_url}','','','',{shopifyIntegrationData.append_shop_email},'','{shopifyIntegrationData.append_third_id}','','','','','','','{shopifyIntegrationData.append_shop_currency}','','','','',0,0,'',{shopifyIntegrationData.append_shop_connect_status},'{shopifyIntegrationData.append_shop_js}',{shopifyIntegrationData.append_integrated_email},0,'v1','{shopifyIntegrationData.append_faq_willdesk_domain}',{shopifyIntegrationData.append_faq_cname_domain},1,'2024-04-23 17:18:55',2,NULL,'2024-04-23 17:18:55','2024-04-23 17:18:55',0); +""" +new_shop_select_sql = f'select * from `shop` where brand_id = {shopifyIntegrationData.brandId} and shop_name = "{shopifyIntegrationData.append_shop_name}" and shop_domain = "{shopifyIntegrationData.append_shop_url}" and is_delete in (0,2) and `source` = {shopifyIntegrationData.shop_source}' +js_shop_insert_sql = f"""INSERT INTO willdesk.shop (company_id,brand_id,`source`,shop_name,website_name,shop_domain,shop_url,shop_owner,phone,email,install_email,third_id,third_token,third_plan,money_format,time_zone,country,country_code,currency,province,city,address,zip,is_review,reviews,`language`,connect_status,shop_js,integrated_email,theme_id,theme_ext_version,faq_willdesk_doamin,faq_cname_domain,embedding_switch,embedding_check_time,is_delete,uninstall_time,create_at,update_at,integration_rdc) VALUES + ({shopifyIntegrationData.companyId},{shopifyIntegrationData.brandId},{shopifyIntegrationData.js_soucrce},'{shopifyIntegrationData.append_shop_name}','','{shopifyIntegrationData.append_shop_url}','','','',{shopifyIntegrationData.append_shop_email},'','{shopifyIntegrationData.append_third_id}','','','','','','','{shopifyIntegrationData.append_shop_currency}','','','','',0,0,'',{shopifyIntegrationData.append_shop_connect_status},'{shopifyIntegrationData.append_shop_js}',{shopifyIntegrationData.append_integrated_email},0,'v1','{shopifyIntegrationData.append_faq_willdesk_domain}',{shopifyIntegrationData.append_faq_cname_domain},1,'2024-04-23 17:18:55',2,NULL,'2024-04-23 17:18:55','2024-04-23 17:18:55',0); +""" +new_js_select_sql = f'select * from `shop` where brand_id = {shopifyIntegrationData.brandId} and shop_name = "{shopifyIntegrationData.append_shop_name}" and shop_domain = "{shopifyIntegrationData.append_shop_url}" and is_delete in (0,2) and `source` = {shopifyIntegrationData.js_soucrce}' + +if shopify_shop_select_result: + shop = shopify_shop_select_result[0] + shop_id = shop['id'] + shop_brand_id = shop['brand_id'] + shop_company_id = shop['company_id'] + shop_name = shop['shop_name'] + shop_domain = shop['shop_domain'] + shop_email = shop['email'] + shop_third_id = shop['third_id'] + shop_currency = shop['currency'] + shop_connect_status = shop['connect_status'] + shop_js = shop['shop_js'] + shop_integrated_email = shop['integrated_email'] + shop_faq_willdesk_domain = shop['faq_willdesk_doamin'] + shop_faq_cname_domain = shop['faq_cname_domain'] if shop['faq_cname_domain'] != None else '' + append_js_id = None + if not hasattr(shopifyIntegrationData, 'append_shop_id'): + test_env_conn.execute_sql(sql=shopify_shop_insert_sql) + new_shop_select_result = test_env_conn.select_one_value(sql=new_shop_select_sql) + append_shop_id = new_shop_select_result['id'] + setattr(shopifyIntegrationData, 'append_shop_id', append_shop_id) + if not hasattr(shopifyIntegrationData, 'append_js_id'): + test_env_conn.execute_sql(sql=js_shop_insert_sql) + new_js_select_result = test_env_conn.select_one_value(sql=new_js_select_sql) + append_js_id = new_shop_select_result['id'] + setattr(shopifyIntegrationData, 'append_js_id', append_js_id) + shop_num = len(test_env_conn.select_many_value(sql=shopify_shop_select_sql)) + setattr(shopifyIntegrationData, 'shop_num', shop_num) +else: + test_env_conn.execute_sql(sql=shopify_shop_insert_sql) + new_shop_select_result = test_env_conn.select_one_value(sql=new_shop_select_sql) + append_shop_id = new_shop_select_result['id'] + new_js_select_result = test_env_conn.select_one_value(sql=new_js_select_sql) + append_js_id = new_shop_select_result['id'] + shop_brand_id = shopifyIntegrationData.brandId + shop_company_id = shopifyIntegrationData.companyId + shop_name = shopifyIntegrationData.append_shop_name + shop_domain = shopifyIntegrationData.append_shop_url + shop_email = shopifyIntegrationData.append_shop_email + shop_third_id = shopifyIntegrationData.append_third_id + shop_js = shopifyIntegrationData.append_shop_js + shop_integrated_email = shopifyIntegrationData.append_integrated_email + shop_faq_willdesk_domain = shopifyIntegrationData.append_faq_willdesk_domain + shop_faq_cname_domain = shopifyIntegrationData.append_faq_cname_domain if shopifyIntegrationData.append_faq_cname_domain != None else '' + shop_currency = shopifyIntegrationData.append_shop_currency + shop_connect_status = shopifyIntegrationData.append_shop_connect_status + shop_id = append_shop_id + setattr(shopifyIntegrationData, 'append_shop_id', append_shop_id) + setattr(shopifyIntegrationData, 'append_js_id', append_js_id) + setattr(shopifyIntegrationData, 'shop_num', 2) +setattr(shopifyIntegrationData, 'shop_id', shop_id) +setattr(shopifyIntegrationData, 'shop_brand_id', shop_brand_id) +setattr(shopifyIntegrationData, 'shop_company_id', shop_company_id) +setattr(shopifyIntegrationData, 'shop_name', shop_name) +setattr(shopifyIntegrationData, 'shop_domain', shop_domain) +setattr(shopifyIntegrationData, 'shop_email', shop_email) +setattr(shopifyIntegrationData, 'shop_third_id', shop_third_id) +setattr(shopifyIntegrationData, 'shop_currency', shop_currency) +setattr(shopifyIntegrationData, 'shop_connect_status', shop_connect_status) +setattr(shopifyIntegrationData, 'shop_js', shop_js) +setattr(shopifyIntegrationData, 'shop_integrated_email', shop_integrated_email) +setattr(shopifyIntegrationData, 'shop_faq_willdesk_domain', shop_faq_willdesk_domain) +setattr(shopifyIntegrationData, 'shop_faq_cname_domain', shop_faq_cname_domain) + diff --git a/YamlCase/setting/shopifyIntegration.yaml b/YamlCase/setting/shopifyIntegration.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f774cb64dd0299d6f52eb22df3196997ec70ff87 --- /dev/null +++ b/YamlCase/setting/shopifyIntegration.yaml @@ -0,0 +1,135 @@ +api1: + title: 新增shopify - 商店集成 + url: /api/v1/shop/add + method: post + data: {"domain":"${append_shop_url}","shopName":"${append_shop_name}","source":2,"v":"${v}"} + set_value: {"append_shop_id": "$.data.id"} + expected: + - eq: {"$.code" : 0} + +api2: + title: 新增shopify - js集成 + url: /api/v1/shop/add + method: post + data: {"domain": "${append_shop_url}","shopName": "${append_shop_name}","source": 1,"v": "${v}" } + set_value: {"append_js_id": "$.data.id"} + expected: + - eq: { "$.code": 0 } + +api3: + title: 检查店铺是否添加成功 + url: /api/v1/shop/local/shopInfoList + method: post + before_sql: setting/shopifyIntegration/shopifyIntegration_shop_select.py + data: {"omitShopSet":true,"omitEmbedding":true,"havePreShop":true,"v":"${v}"} + expected: + - eq: {"$.code" : 0} + - in_list: {"$.data.list[*].id": "${append_shop_id}"} + - in_list: {"$.data.list[*].id": "${append_js_id}"} + +api4: + title: 检查店铺信息 + url: /api/v1/shop/local/shopInfoList + method: post + data: {"omitShopSet":true,"omitEmbedding":true,"havePreShop":true,"v":"${v}"} + expected: + - eq: {"$.code" : 0} + - eq: {"$.data.list[?(@.id == ${shop_id})].brandId": "${shop_brand_id}"} + - eq: {"$.data.list[?(@.id == ${shop_id})].companyId": "${shop_company_id}"} + - eq: {"$.data.list[?(@.id == ${shop_id})].shopName": "${shop_name}"} + - eq: {"$.data.list[?(@.id == ${shop_id})].shopDomain": "${shop_domain}"} + - eq: {"$.data.list[?(@.id == ${shop_id})].email": "${shop_email}" } + - eq: {"$.data.list[?(@.id == ${shop_id})].shopJs": "${shop_js}" } + - eq: {"$.data.list[?(@.id == ${shop_id})].integratedEmail": "${shop_integrated_email}" } + - eq: {"$.data.list[?(@.id == ${shop_id})].faqWilldeskDoamin": "${shop_faq_willdesk_domain}" } + - eq: {"$.data.list[?(@.id == ${shop_id})].faqCnameDomain": "${shop_faq_cname_domain}" } + - eq: {"$.data.list[?(@.id == ${shop_id})].currency": "${shop_currency}" } + - eq: {"$.data.list[?(@.id == ${shop_id})].connectStatus": "${shop_connect_status}" } + - eq: {"$.data.list[?(@.id == ${shop_id})].thirdId": "${shop_third_id}" } + - exec: {"code": "assert len(res.json()['data']['list']) == ${shop_num}"} + +api5: + title: 更新店铺信息 + url: /api/v1/shop/edit + method: post + data: {"id":"${append_shop_id}","shopName":"${update_shop_name}","v":"${v}"} + expected: + - eq: {"$.code" : 0} + +api6: + title: 关联店铺邮箱 + url: /api/v1/shop/local/updateShopIntegratedEmail + method: post + data: {"shopId":"${append_shop_id}","integratedEmail":"${active_shop_email}","v":"${v}"} + expected: + - eq: {"$.code" : 0} + +api7: + title: 检查店铺信息 + url: /api/v1/shop/local/shopInfoList + method: post + data: {"omitShopSet":true,"omitEmbedding":true,"havePreShop":true,"v":"${v}"} + expected: + - eq: {"$.code" : 0} + - eq: {"$.data.list[?(@.id == ${append_shop_id})].integratedEmail": "${active_shop_email}" } + - eq: {"$.data.list[?(@.id == ${append_shop_id})].shopName": "${update_shop_name}" } + +api8: + title: 删除店铺 + url: /api/v1/shop/delete + method: post + data: {"shopId":"${append_shop_id}","v":"${v}"} + expected: + - eq: {"$.code" : 0} + +api9: + title: 删除店铺 + url: /api/v1/shop/delete + method: post + data: {"shopId":"${append_js_id}","v":"${v}"} + expected: + - eq: {"$.code" : 0} + +api10: + title: 检查店铺是否删除成功 + url: /api/v1/shop/local/shopInfoList + method: post + data: {"omitShopSet": true,"omitEmbedding": true,"havePreShop": true,"v": "${v}" } + expected: + - eq: { "$.code": 0 } + - not_in_list: {"$.data.list[*].id": "${append_shop_id}"} + - not_in_list: {"$.data.list[*].id": "${append_js_id}"} + +api11: + title: 编辑工作区名称 + url: /api/v1/brand/changeName + method: post + data: {name: "${new_workspance_name}", v: "${v}"} + expected: + - eq: {"$.code": 0 } + +api12: + title: 检查工作区名称是否更新 + url: /api/v1/customerService/getCustomerServiceInfo?v=${v} + method: get + expected: + - eq: {"$.code": 0 } + - eq: {"$.data.brandName": "${new_workspance_name}" } + + +api13: + title: 还原工作区名称 + url: /api/v1/brand/changeName + method: post + data: {name: "${brandName}", v: "${v}"} + expected: + - eq: {"$.code": 0 } + +api14: + title: 检查工作区名称是否还原 + url: /api/v1/customerService/getCustomerServiceInfo?v=${v} + method: get + expected: + - eq: {"$.code": 0 } + - eq: {"$.data.brandName": "${brandName}" } +