Skip to content

Commit

Permalink
bugfix/frontend-width-overflow (#29)
Browse files Browse the repository at this point in the history
* Fix frontend width overflow; Add error log when load base failure

* add pytest
  • Loading branch information
yumiguan committed Jan 4, 2021
1 parent a135990 commit 2dc1981
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 19 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ jobs:
pip install -r requirements.txt
pip install .
- name: Unit Test
run: pytest
run: |
cd tests
python -m pytest .
2 changes: 1 addition & 1 deletion frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ export default {

<style scoped>
#app {
min-width: 1500px;
min-width: 1390px;
}
</style>
5 changes: 2 additions & 3 deletions frontend/src/components/apiList.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div id="tab" class="box box-solid">
<div class="box-body" style="height:80vh; overflow:auto">
<i-table height="1000" stripe :columns="columns" :data="showedAPIData" ></i-table>
<div class="box-body" style="max-height:calc(100vh - 100px); overflow:auto">
<i-table stripe :columns="columns" :data="showedAPIData" ></i-table>
<Modal
v-model="isApiDetailModalShow"
title="Flow Detail"
Expand Down Expand Up @@ -134,7 +134,6 @@ export default {

<style scoped>
#tab {
background-color: pink;
width: 100%;
height: 100%;
margin-top: 30px;
Expand Down
8 changes: 3 additions & 5 deletions frontend/src/components/banner.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<Row>
<i-col span="18" class="colLeft">
<i-col span="24" class="colLeft">
<Button
class="btn"
:size="buttonSize"
Expand Down Expand Up @@ -77,8 +77,6 @@
</div>
</form>
</modal>
</i-col>
<i-col span="6" class="colRight">
<Input
class="searchInput"
v-model="targetContext"
Expand Down Expand Up @@ -318,9 +316,9 @@ export default {
.colLeft .btn {
margin: 10px 5px 10px 5px;
}
.colRight .searchInput {
.colLeft .searchInput {
margin: 10px 5px 10px 5px;
width: 300px;
min-width: 350px;
float: right;
}
</style>
17 changes: 13 additions & 4 deletions lyrebird_api_coverage/handlers/base_source_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lyrebird
from lyrebird.mock import context
from lyrebird.log import get_logger

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

logger = get_logger()

'''
Base 处理器
'''
Expand All @@ -31,9 +34,10 @@ def get_base_source(self):
json_obj = context.make_fail_response('暂无默认文件,需手动导入base文件')
# 检查不为空的base文件是否符合标准,符合标准check_base返回0
else:
if self.check_base(json_obj):
error_response = self.check_base(json_obj)
if error_response:
# 遇到异常就返回
return self.check_base(json_obj)
return error_response
return json_obj

'''
Expand All @@ -46,6 +50,12 @@ def check_base(self, obj):
# 检查url是否有重复项存在
redundant_items = check_url_redundant(obj)
if redundant_items:
redundant_items_str = '\n'.join(redundant_items)
logger.error(
f'API-Coverage import API file error: Duplicated API\n'
f'{len(redundant_items)} duplicated API:\n'
f'{redundant_items_str}\n'
)
resp = context.make_fail_response('导入API有重复项' + str(redundant_items))
lyrebird.publish('api_coverage', 'error', name='import_base')
return resp
Expand All @@ -57,7 +67,6 @@ def check_base(self, obj):
app_context.version_code = obj.get('version_code')
return
except Exception as e:
resp = context.make_fail_response(
'导入文件有误:' + '\n' + e.__getattribute__('message') + '\n' + '!请重新import base')
resp = context.make_fail_response(f'导入文件有误: {e}\n请重新import base')

return resp
2 changes: 1 addition & 1 deletion lyrebird_api_coverage/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
IVERSION = (0, 3, 0)
IVERSION = (0, 3, 1)
VERSION = ".".join(str(i) for i in IVERSION)
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
lyrebird
jsonschema
-e .[dev]
10 changes: 8 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
install_requires=[
'lyrebird',
'jsonschema'
]

],
extras_require={
'dev': [
"autopep8",
"pylint",
"pytest"
]
}
)

0 comments on commit 2dc1981

Please sign in to comment.