Commit 34349dc7 by zhaihuitao
parents 918632d6 7b09414e
# Default ignored files
/shelf/
/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyChainedComparisonsInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoreConstantInTheMiddle" value="true" />
</inspection_tool>
</profile>
</component>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/gatling-monitor.iml" filepath="$PROJECT_DIR$/.idea/gatling-monitor.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
运行
\ No newline at end of file
body {
font-family: Helvetica, Arial, sans-serif;
font-size: 12px;
/* do not increase min-width as some may use split screens */
min-width: 800px;
color: #999;
}
h1 {
font-size: 24px;
color: black;
}
h2 {
font-size: 16px;
color: black;
}
p {
color: black;
}
a {
color: #999;
}
table {
border-collapse: collapse;
}
/******************************
* SUMMARY INFORMATION
******************************/
#environment td {
padding: 5px;
border: 1px solid #E6E6E6;
}
#environment tr:nth-child(odd) {
background-color: #f6f6f6;
}
/******************************
* TEST RESULT COLORS
******************************/
span.passed,
.passed .col-result {
color: green;
}
span.skipped,
span.xfailed,
span.rerun,
.skipped .col-result,
.xfailed .col-result,
.rerun .col-result {
color: orange;
}
span.error,
span.failed,
span.xpassed,
.error .col-result,
.failed .col-result,
.xpassed .col-result {
color: red;
}
/******************************
* RESULTS TABLE
*
* 1. Table Layout
* 2. Extra
* 3. Sorting items
*
******************************/
/*------------------
* 1. Table Layout
*------------------*/
#results-table {
border: 1px solid #e6e6e6;
color: #999;
font-size: 12px;
width: 100%;
}
#results-table th,
#results-table td {
padding: 5px;
border: 1px solid #E6E6E6;
text-align: left;
}
#results-table th {
font-weight: bold;
}
/*------------------
* 2. Extra
*------------------*/
.log {
background-color: #e6e6e6;
border: 1px solid #e6e6e6;
color: black;
display: block;
font-family: "Courier New", Courier, monospace;
height: 230px;
overflow-y: scroll;
padding: 5px;
white-space: pre-wrap;
}
.log:only-child {
height: inherit;
}
div.image {
border: 1px solid #e6e6e6;
float: right;
height: 240px;
margin-left: 5px;
overflow: hidden;
width: 320px;
}
div.image img {
width: 320px;
}
div.video {
border: 1px solid #e6e6e6;
float: right;
height: 240px;
margin-left: 5px;
overflow: hidden;
width: 320px;
}
div.video video {
overflow: hidden;
width: 320px;
height: 240px;
}
.collapsed {
display: none;
}
.expander::after {
content: " (show details)";
color: #BBB;
font-style: italic;
cursor: pointer;
}
.collapser::after {
content: " (hide details)";
color: #BBB;
font-style: italic;
cursor: pointer;
}
/*------------------
* 3. Sorting items
*------------------*/
.sortable {
cursor: pointer;
}
.sort-icon {
font-size: 0px;
float: left;
margin-right: 5px;
margin-top: 5px;
/*triangle*/
width: 0;
height: 0;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
}
.inactive .sort-icon {
/*finish triangle*/
border-top: 8px solid #E6E6E6;
}
.asc.active .sort-icon {
/*finish triangle*/
border-bottom: 8px solid #999;
}
.desc.active .sort-icon {
/*finish triangle*/
border-top: 8px solid #999;
}
# -*- coding: utf-8 -*-
"""
# @Time : 2022/3/8 10:35
# @Author : zhaiht
# @File : config.py
# @desc :
"""
Headers = {'Authorization': 'Bearer 3ba9c1c1-b398-472e-8ae4-b621ba52e283',
'Content-Type': 'application/json;charset=UTF-8'}
url_test = "http://117.50.4.194"
url_prod = "http://gatling.reyun.com"
p2v = "/api-f/batchIm2Video/asyncBatchImg2V"
v2v = "/api-f/video2video/generatedAsync/false"
t2v = "/api-f/text2video/asyncGenerated"
# -*- coding: utf-8 -*-
"""
# @Time : 2022/3/8 09:56
# @Author : zhaiht
# @File : param.py
# @desc :
"""
import json
title_id = json.load(open('title_id.json', 'r+'))['title_id'] + 1
json.dump({"title_id": title_id}, open('title_id.json', 'w+'), sort_keys=True, indent=4)
p2v = json.dumps({
"sizeId": 5,
"title": title_id,
"resultRule": "{标题}_{日期}_{序号}",
"img2VideoList": [
{
"content": "",
"duration": "10",
"floatLogoAlpha": 0.4,
"floatLogoMoveType": "NONE",
"floatLogoSpeed": 1,
"logoIndex": 1,
"musicUrl": "",
"recommendFlag": True,
"soundEffect": "fadeInOut",
"textIndex": 9,
"volumeNum": 30,
"combinationResList": [
{
"path": "root/image/jpg/9816ffcb5bf2454fac66377424d20be1.jpg",
"imgUrl": "https://gatling.cn-bj.ufileos.com/root%2Fimage%2Fjpg%2F9816ffcb5bf2454fac66377424d20be1.jpg?UCloudPublicKey=TOKEN_2ec337cb-d655-4803-9b2c-f1bb6af60cd6&Signature=9gmwB7ibSS1rcf0rNe%2FAYHinypg%3D&Expires=1645092905",
"duration": 5000
},
{
"path": "root/image/jpg/05dbaeba887145399dfbeda7a43f94f3.jpg",
"imgUrl": "https://gatling.cn-bj.ufileos.com/root%2Fimage%2Fjpg%2F05dbaeba887145399dfbeda7a43f94f3.jpg?UCloudPublicKey=TOKEN_2ec337cb-d655-4803-9b2c-f1bb6af60cd6&Signature=eN4KRWlhGH7C8hh3%2FSDkMcyQWpY%3D&Expires=1645092905",
"duration": 5000
}
]
}
],
"local": False,
"library": True
})
#######################################################
v2v = json.dumps({
"type": "video",
"music": "auto",
"ossCloud": True,
"sizeId": 6,
"title": title_id,
"resultRule": "{标题}_{序号}",
"videoParamGroups": [
{
"videoCombinations": [
{
"id": "1493837922917515264",
"type": "video",
"path": "root/video/mp4/f010e2a2294c4def9775c899bcbe2a13.mp4",
"ossVideoUrl": None,
"ossImageUrl": "https://gatling.cn-bj.ufileos.com/root%2Fimage%2Fjpg%2F2072a63727c74803ab5aace0f02fa878.jpg?UCloudPublicKey=TOKEN_2ec337cb-d655-4803-9b2c-f1bb6af60cd6&Signature=fwvdV3r%2BY6bHkLae%2BsSE5Ty9ByY%3D&Expires=1645513048",
"duration": None,
"soundEffect": None,
"volumeNum": None,
"musicUrl": None,
"logoIndex": 1,
"fontSize": None,
"content": None,
"fontFileUrl": None,
"textIndex": 9,
"floatLogoAlpha": 0.4,
"floatLogoSpeed": 1,
"floatLogoMoveType": "DEFAULT01",
"templateLevelDtos": None
},
{
"id": "1470667240268472320",
"type": "video",
"path": "root/video/mp4/51b855ab63eb4b9b89dc6550bc56e944.mp4",
"ossVideoUrl": None,
"ossImageUrl": "https://gatling.cn-bj.ufileos.com/root%2Fvideo%2Fmp4%2F66560d3cd5bd437ea96152af09769ada.mp4?UCloudPublicKey=TOKEN_2ec337cb-d655-4803-9b2c-f1bb6af60cd6&Signature=K2eRQq%2FDRWLgjpJ4OUiYoXWDJFo%3D&Expires=1645513048",
"duration": None,
"soundEffect": None,
"volumeNum": None,
"musicUrl": None,
"logoIndex": 1,
"fontSize": None,
"content": None,
"fontFileUrl": None,
"textIndex": 9,
"floatLogoAlpha": 0.4,
"floatLogoSpeed": 1,
"floatLogoMoveType": "DEFAULT01",
"templateLevelDtos": None
}
],
"name": "项目名称_20220217145806_1"
}
]
})
##############################
t2v = json.dumps({
"title": "文字转视频_20220308161829",
"text2VideoList": [
{
"filename": "文字转视频_20220308161829_1",
"logoIndex": 1,
"musicUrl": "",
"templateId": "1483357236767072256",
"textId": "1479412167945068544",
"warningContent": "",
"warningIndex": 9,
"watermarkAlpha": 0.4,
"watermarkSpeed": 2
}
],
"local": False,
"library": True
})
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Test Report</title>
<link href="assets/style.css" rel="stylesheet" type="text/css"/></head>
<body onLoad="init()">
<script>/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
function toArray(iter) {
if (iter === null) {
return null;
}
return Array.prototype.slice.call(iter);
}
function find(selector, elem) { // eslint-disable-line no-redeclare
if (!elem) {
elem = document;
}
return elem.querySelector(selector);
}
function findAll(selector, elem) {
if (!elem) {
elem = document;
}
return toArray(elem.querySelectorAll(selector));
}
function sortColumn(elem) {
toggleSortStates(elem);
const colIndex = toArray(elem.parentNode.childNodes).indexOf(elem);
let key;
if (elem.classList.contains('result')) {
key = keyResult;
} else if (elem.classList.contains('links')) {
key = keyLink;
} else {
key = keyAlpha;
}
sortTable(elem, key(colIndex));
}
function showAllExtras() { // eslint-disable-line no-unused-vars
findAll('.col-result').forEach(showExtras);
}
function hideAllExtras() { // eslint-disable-line no-unused-vars
findAll('.col-result').forEach(hideExtras);
}
function showExtras(colresultElem) {
const extras = colresultElem.parentNode.nextElementSibling;
const expandcollapse = colresultElem.firstElementChild;
extras.classList.remove('collapsed');
expandcollapse.classList.remove('expander');
expandcollapse.classList.add('collapser');
}
function hideExtras(colresultElem) {
const extras = colresultElem.parentNode.nextElementSibling;
const expandcollapse = colresultElem.firstElementChild;
extras.classList.add('collapsed');
expandcollapse.classList.remove('collapser');
expandcollapse.classList.add('expander');
}
function showFilters() {
const filterItems = document.getElementsByClassName('filter');
for (let i = 0; i < filterItems.length; i++)
filterItems[i].hidden = false;
}
function addCollapse() {
// Add links for show/hide all
const resulttable = find('table#results-table');
const showhideall = document.createElement('p');
showhideall.innerHTML = '<a href="javascript:showAllExtras()">Show all details</a> / ' +
'<a href="javascript:hideAllExtras()">Hide all details</a>';
resulttable.parentElement.insertBefore(showhideall, resulttable);
// Add show/hide link to each result
findAll('.col-result').forEach(function(elem) {
const collapsed = getQueryParameter('collapsed') || 'Passed';
const extras = elem.parentNode.nextElementSibling;
const expandcollapse = document.createElement('span');
if (extras.classList.contains('collapsed')) {
expandcollapse.classList.add('expander');
} else if (collapsed.includes(elem.innerHTML)) {
extras.classList.add('collapsed');
expandcollapse.classList.add('expander');
} else {
expandcollapse.classList.add('collapser');
}
elem.appendChild(expandcollapse);
elem.addEventListener('click', function(event) {
if (event.currentTarget.parentNode.nextElementSibling.classList.contains('collapsed')) {
showExtras(event.currentTarget);
} else {
hideExtras(event.currentTarget);
}
});
});
}
function getQueryParameter(name) {
const match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
}
function init () { // eslint-disable-line no-unused-vars
resetSortHeaders();
addCollapse();
showFilters();
sortColumn(find('.initial-sort'));
findAll('.sortable').forEach(function(elem) {
elem.addEventListener('click',
function() {
sortColumn(elem);
}, false);
});
}
function sortTable(clicked, keyFunc) {
const rows = findAll('.results-table-row');
const reversed = !clicked.classList.contains('asc');
const sortedRows = sort(rows, keyFunc, reversed);
/* Whole table is removed here because browsers acts much slower
* when appending existing elements.
*/
const thead = document.getElementById('results-table-head');
document.getElementById('results-table').remove();
const parent = document.createElement('table');
parent.id = 'results-table';
parent.appendChild(thead);
sortedRows.forEach(function(elem) {
parent.appendChild(elem);
});
document.getElementsByTagName('BODY')[0].appendChild(parent);
}
function sort(items, keyFunc, reversed) {
const sortArray = items.map(function(item, i) {
return [keyFunc(item), i];
});
sortArray.sort(function(a, b) {
const keyA = a[0];
const keyB = b[0];
if (keyA == keyB) return 0;
if (reversed) {
return keyA < keyB ? 1 : -1;
} else {
return keyA > keyB ? 1 : -1;
}
});
return sortArray.map(function(item) {
const index = item[1];
return items[index];
});
}
function keyAlpha(colIndex) {
return function(elem) {
return elem.childNodes[1].childNodes[colIndex].firstChild.data.toLowerCase();
};
}
function keyLink(colIndex) {
return function(elem) {
const dataCell = elem.childNodes[1].childNodes[colIndex].firstChild;
return dataCell == null ? '' : dataCell.innerText.toLowerCase();
};
}
function keyResult(colIndex) {
return function(elem) {
const strings = ['Error', 'Failed', 'Rerun', 'XFailed', 'XPassed',
'Skipped', 'Passed'];
return strings.indexOf(elem.childNodes[1].childNodes[colIndex].firstChild.data);
};
}
function resetSortHeaders() {
findAll('.sort-icon').forEach(function(elem) {
elem.parentNode.removeChild(elem);
});
findAll('.sortable').forEach(function(elem) {
const icon = document.createElement('div');
icon.className = 'sort-icon';
icon.textContent = 'vvv';
elem.insertBefore(icon, elem.firstChild);
elem.classList.remove('desc', 'active');
elem.classList.add('asc', 'inactive');
});
}
function toggleSortStates(elem) {
//if active, toggle between asc and desc
if (elem.classList.contains('active')) {
elem.classList.toggle('asc');
elem.classList.toggle('desc');
}
//if inactive, reset all other functions and add ascending active
if (elem.classList.contains('inactive')) {
resetSortHeaders();
elem.classList.remove('inactive');
elem.classList.add('active');
}
}
function isAllRowsHidden(value) {
return value.hidden == false;
}
function filterTable(elem) { // eslint-disable-line no-unused-vars
const outcomeAtt = 'data-test-result';
const outcome = elem.getAttribute(outcomeAtt);
const classOutcome = outcome + ' results-table-row';
const outcomeRows = document.getElementsByClassName(classOutcome);
for(let i = 0; i < outcomeRows.length; i++){
outcomeRows[i].hidden = !elem.checked;
}
const rows = findAll('.results-table-row').filter(isAllRowsHidden);
const allRowsHidden = rows.length == 0 ? true : false;
const notFoundMessage = document.getElementById('not-found-message');
notFoundMessage.hidden = !allRowsHidden;
}
</script>
<h1>report.html</h1>
<p>Report generated on 08-Mar-2022 at 16:51:09 by <a href="https://pypi.python.org/pypi/pytest-html">pytest-html</a> v3.1.1</p>
<h2>Environment</h2>
<table id="environment">
<tr>
<td>JAVA_HOME</td>
<td>/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home</td></tr>
<tr>
<td>Packages</td>
<td>{"pluggy": "1.0.0", "py": "1.11.0", "pytest": "6.2.5"}</td></tr>
<tr>
<td>Platform</td>
<td>macOS-11.0.1-x86_64-i386-64bit</td></tr>
<tr>
<td>Plugins</td>
<td>{"html": "3.1.1", "metadata": "1.11.0"}</td></tr>
<tr>
<td>Python</td>
<td>3.9.0</td></tr></table>
<h2>Summary</h2>
<p>3 tests ran in 0.37 seconds. </p>
<p class="filter" hidden="true">(Un)check the boxes to filter the results.</p><input checked="true" class="filter" data-test-result="passed" hidden="true" name="filter_checkbox" onChange="filterTable(this)" type="checkbox"/><span class="passed">3 passed</span>, <input checked="true" class="filter" data-test-result="skipped" disabled="true" hidden="true" name="filter_checkbox" onChange="filterTable(this)" type="checkbox"/><span class="skipped">0 skipped</span>, <input checked="true" class="filter" data-test-result="failed" disabled="true" hidden="true" name="filter_checkbox" onChange="filterTable(this)" type="checkbox"/><span class="failed">0 failed</span>, <input checked="true" class="filter" data-test-result="error" disabled="true" hidden="true" name="filter_checkbox" onChange="filterTable(this)" type="checkbox"/><span class="error">0 errors</span>, <input checked="true" class="filter" data-test-result="xfailed" disabled="true" hidden="true" name="filter_checkbox" onChange="filterTable(this)" type="checkbox"/><span class="xfailed">0 expected failures</span>, <input checked="true" class="filter" data-test-result="xpassed" disabled="true" hidden="true" name="filter_checkbox" onChange="filterTable(this)" type="checkbox"/><span class="xpassed">0 unexpected passes</span>
<h2>Results</h2>
<table id="results-table">
<thead id="results-table-head">
<tr>
<th class="sortable result initial-sort" col="result">Result</th>
<th class="sortable" col="name">Test</th>
<th class="sortable" col="duration">Duration</th>
<th class="sortable links" col="links">Links</th></tr>
<tr hidden="true" id="not-found-message">
<th colspan="4">No results found. Try to check the filters</th></tr></thead>
<tbody class="passed results-table-row">
<tr>
<td class="col-result">Passed</td>
<td class="col-name">testcase.py::TestGatlingAPI::test_p2v</td>
<td class="col-duration">0.08</td>
<td class="col-links"></td></tr>
<tr>
<td class="extra" colspan="4">
<div class="empty log">No log output captured.</div></td></tr></tbody>
<tbody class="passed results-table-row">
<tr>
<td class="col-result">Passed</td>
<td class="col-name">testcase.py::TestGatlingAPI::test_v2v</td>
<td class="col-duration">0.05</td>
<td class="col-links"></td></tr>
<tr>
<td class="extra" colspan="4">
<div class="empty log">No log output captured.</div></td></tr></tbody>
<tbody class="passed results-table-row">
<tr>
<td class="col-result">Passed</td>
<td class="col-name">testcase.py::TestGatlingAPI::test_tv2</td>
<td class="col-duration">0.06</td>
<td class="col-links"></td></tr>
<tr>
<td class="extra" colspan="4">
<div class="empty log">No log output captured.</div></td></tr></tbody></table></body></html>
\ No newline at end of file
# -*- coding: utf-8 -*-
"""
# @Time : 2022/3/8 10:10
# @Author : zhaiht
# @File : testcase.py
# @desc :
"""
import json
import pytest
import requests
import param
import config
class TestGatlingAPI:
def test_p2v(self):
r = requests.post(url=config.url_prod + config.p2v, data=param.p2v, headers=config.Headers)
print(r.text)
assert r.status_code == 200
def test_v2v(self):
r = requests.post(url=config.url_prod + config.v2v, data=param.v2v, headers=config.Headers)
print(r.text)
assert r.status_code == 200
def test_tv2(self):
r = requests.post(url=config.url_prod + config.t2v, data=param.t2v, headers=config.Headers)
print(r.text)
assert r.status_code == 200
{
"title_id": 20220340
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment