Skip to content

Commit 2dc1981

Browse files
authored
bugfix/frontend-width-overflow (#29)
* Fix frontend width overflow; Add error log when load base failure * add pytest
1 parent a135990 commit 2dc1981

File tree

8 files changed

+32
-19
lines changed

8 files changed

+32
-19
lines changed

.github/workflows/unittest.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@ jobs:
1818
pip install -r requirements.txt
1919
pip install .
2020
- name: Unit Test
21-
run: pytest
21+
run: |
22+
cd tests
23+
python -m pytest .

frontend/src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ export default {
6565

6666
<style scoped>
6767
#app {
68-
min-width: 1500px;
68+
min-width: 1390px;
6969
}
7070
</style>

frontend/src/components/apiList.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div id="tab" class="box box-solid">
3-
<div class="box-body" style="height:80vh; overflow:auto">
4-
<i-table height="1000" stripe :columns="columns" :data="showedAPIData" ></i-table>
3+
<div class="box-body" style="max-height:calc(100vh - 100px); overflow:auto">
4+
<i-table stripe :columns="columns" :data="showedAPIData" ></i-table>
55
<Modal
66
v-model="isApiDetailModalShow"
77
title="Flow Detail"
@@ -134,7 +134,6 @@ export default {
134134

135135
<style scoped>
136136
#tab {
137-
background-color: pink;
138137
width: 100%;
139138
height: 100%;
140139
margin-top: 30px;

frontend/src/components/banner.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<Row>
3-
<i-col span="18" class="colLeft">
3+
<i-col span="24" class="colLeft">
44
<Button
55
class="btn"
66
:size="buttonSize"
@@ -77,8 +77,6 @@
7777
</div>
7878
</form>
7979
</modal>
80-
</i-col>
81-
<i-col span="6" class="colRight">
8280
<Input
8381
class="searchInput"
8482
v-model="targetContext"
@@ -318,9 +316,9 @@ export default {
318316
.colLeft .btn {
319317
margin: 10px 5px 10px 5px;
320318
}
321-
.colRight .searchInput {
319+
.colLeft .searchInput {
322320
margin: 10px 5px 10px 5px;
323321
width: 300px;
324-
min-width: 350px;
322+
float: right;
325323
}
326324
</style>

lyrebird_api_coverage/handlers/base_source_handler.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import lyrebird
44
from lyrebird.mock import context
5+
from lyrebird.log import get_logger
56

67
from lyrebird_api_coverage.client.context import app_context
78
from lyrebird_api_coverage.client.jsonscheme import check_schema, check_url_redundant
@@ -17,6 +18,8 @@
1718
# 默认base 文件
1819
DEFAULT_BASE = os.path.join(PLUGINS_CONF_DIR, 'base.json')
1920

21+
logger = get_logger()
22+
2023
'''
2124
Base 处理器
2225
'''
@@ -31,9 +34,10 @@ def get_base_source(self):
3134
json_obj = context.make_fail_response('暂无默认文件,需手动导入base文件')
3235
# 检查不为空的base文件是否符合标准,符合标准check_base返回0
3336
else:
34-
if self.check_base(json_obj):
37+
error_response = self.check_base(json_obj)
38+
if error_response:
3539
# 遇到异常就返回
36-
return self.check_base(json_obj)
40+
return error_response
3741
return json_obj
3842

3943
'''
@@ -46,6 +50,12 @@ def check_base(self, obj):
4650
# 检查url是否有重复项存在
4751
redundant_items = check_url_redundant(obj)
4852
if redundant_items:
53+
redundant_items_str = '\n'.join(redundant_items)
54+
logger.error(
55+
f'API-Coverage import API file error: Duplicated API\n'
56+
f'{len(redundant_items)} duplicated API:\n'
57+
f'{redundant_items_str}\n'
58+
)
4959
resp = context.make_fail_response('导入API有重复项' + str(redundant_items))
5060
lyrebird.publish('api_coverage', 'error', name='import_base')
5161
return resp
@@ -57,7 +67,6 @@ def check_base(self, obj):
5767
app_context.version_code = obj.get('version_code')
5868
return
5969
except Exception as e:
60-
resp = context.make_fail_response(
61-
'导入文件有误:' + '\n' + e.__getattribute__('message') + '\n' + '!请重新import base')
70+
resp = context.make_fail_response(f'导入文件有误: {e}\n请重新import base')
6271

6372
return resp

lyrebird_api_coverage/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
IVERSION = (0, 3, 0)
1+
IVERSION = (0, 3, 1)
22
VERSION = ".".join(str(i) for i in IVERSION)

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
lyrebird
2-
jsonschema
1+
-e .[dev]

setup.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
install_requires=[
3636
'lyrebird',
3737
'jsonschema'
38-
]
39-
38+
],
39+
extras_require={
40+
'dev': [
41+
"autopep8",
42+
"pylint",
43+
"pytest"
44+
]
45+
}
4046
)

0 commit comments

Comments
 (0)