优化时间格式转时间戳

This commit is contained in:
遥爸 2023-02-23 17:48:37 +08:00
parent 004c4fd656
commit f7592264b7
6 changed files with 87 additions and 36 deletions

View File

@ -49,7 +49,7 @@ platform_index_01:
sql:
platform_property_01:
platform_property_02:
host: ${{host()}}
url: /v1/service/service/property
method: get
@ -78,26 +78,77 @@ platform_property_01:
AssertType:
sql:
#platform-goods-list_01:
# host: ${{host()}}
# url: /v1/service/service/platform-goods-list
# method: get
# detail: 获取商品详情
# headers:
# Connection: 'keep-alive'
# clientSource: '0'
# areaCode: '440105'
# content-type: 'application/json'
# requestType: params
# is_run:
# data:
# fields: "goodsProperty,isNeedMatchCar,matchProperty,sort"
# thirdPartySource: JEKUNAUTO
# carLicense:
# frontServiceId: 1
# dependence_case:
# dependence_case_data:
#
# assert:
# status_code: 200
# sql:
platform_goods_list_03:
host: ${{host()}}
url: /v1/service/service/platform-goods-list
method: get
detail: 获取商品详情
headers:
Connection: 'keep-alive'
clientSource: '0'
areaCode: '440105'
content-type: 'application/json'
requestType: params
is_run:
data:
fields: "goods,after"
thirdPartySource: JEKUNAUTO
carLicense: "粤AAAA02"
frontServiceId: 1
goodsPropertyItemIds: []
dependence_case:
dependence_case_data:
assert:
status_code: 200
sql:
platform_goods_comment_04:
host: ${{host()}}
url: /v1/order/order-goods-comment/latest
method: get
detail: 商品最新评价
headers:
Connection: 'keep-alive'
clientSource: '0'
areaCode: '440105'
content-type: 'application/json'
from: 1082943R5J4DKfcE
requestType: params
is_run:
data:
fields: "*"
thirdPartySource: JEKUNAUTO
goodsId: "1"
dependence_case:
dependence_case_data:
assert:
status_code: 200
sql:
platform_goods_total_05:
host: ${{host()}}
url: /v1/order/order-goods-comment/latest
method: get
detail: 获取商品total
headers:
Connection: 'keep-alive'
clientSource: '0'
areaCode: '440105'
content-type: 'application/json'
from: 1082943R5J4DKfcE
requestType: params
is_run:
data:
fields: "*"
thirdPartySource: JEKUNAUTO
goodsId: "1"
dependence_case:
dependence_case_data:
assert:
status_code: 200
sql:

View File

@ -179,4 +179,4 @@ user_info_car_01:
assert:
# 断言接口状态码
status_code: 200
sql:
sql:

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2023-02-22 15:45:30
# @Time : 2023-02-22 17:48:25
import allure
@ -12,7 +12,7 @@ from utils.read_files_tools.regular_control import regular
from utils.requests_tool.teardown_control import TearDownHandler
case_id = ['platform_index_01', 'platform_property_01']
case_id = ['platform_index_01', 'platform_property_02', 'platform_goods_list_03', 'platform_goods_comment_04', 'platform_goods_total_05']
TestData = GetTestCase.case_data(case_id)
re_data = regular(str(TestData))

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2023-02-22 15:45:30
# @Time : 2023-02-22 17:48:25
import allure

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2023-02-22 15:45:30
# @Time : 2023-02-22 17:48:25
import allure

View File

@ -9,7 +9,6 @@ import time
from typing import Text
from datetime import datetime
def count_milliseconds():
"""
计算时间
@ -21,7 +20,7 @@ def count_milliseconds():
return access_delta
def timestamp_conversion(time_str: Text) -> int:
def timestamp_conversion(time_str: Text) -> float:
"""
时间戳转换将日期格式转换成时间戳
:param time_str: 时间
@ -30,15 +29,16 @@ def timestamp_conversion(time_str: Text) -> int:
try:
datetime_format = datetime.strptime(str(time_str), "%Y-%m-%d %H:%M:%S")
timestamp = int(
time.mktime(datetime_format.timetuple()) * 1000.0
+ datetime_format.microsecond / 1000.0
)
# timestamp = int(
# time.mktime(datetime_format.timetuple()) * 1000.0
# + datetime_format.microsecond / 1000.0
# )
timestamp = datetime.timestamp(datetime_format)
return timestamp
except ValueError as exc:
raise ValueError('日期格式错误, 需要传入得格式为 "%Y-%m-%d %H:%M:%S" ') from exc
a = 111
def time_conversion(time_num: int):
"""
时间戳转换成日期