Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
openEuler-Advisor
提交
20de8b73
O
openEuler-Advisor
项目概览
openeuler
/
openEuler-Advisor
通知
35
Star
4
Fork
4
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
openEuler-Advisor
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
20de8b73
编写于
7月 02, 2020
作者:
S
solarhu
提交者:
Gitee
7月 02, 2020
浏览文件
操作
浏览文件
下载
差异文件
!21 Add test cases and modify functional code
Merge pull request !21 from 包成强/master
上级
e7deccfe
9998981e
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
530 addition
and
24 deletion
+530
-24
packageship/packageship/application/apps/package/function/be_depend.py
...ackageship/application/apps/package/function/be_depend.py
+25
-23
packageship/test/common_files/correct_test_result_json/be_depend.json
...test/common_files/correct_test_result_json/be_depend.json
+131
-0
packageship/test/run_tests.py
packageship/test/run_tests.py
+2
-1
packageship/test/test_module/dependent_query_tests/test_be_depend.py
.../test/test_module/dependent_query_tests/test_be_depend.py
+372
-0
未找到文件。
packageship/packageship/application/apps/package/function/be_depend.py
浏览文件 @
20de8b73
...
...
@@ -127,10 +127,6 @@ class BeDepend:
source_name
=
obj
.
source_name
if
obj
.
bebuild_src_name
:
# Determine if the source package has been checked
if
obj
.
bebuild_src_name
not
in
self
.
source_name_set
:
self
.
source_name_set
.
add
(
obj
.
bebuild_src_name
)
source_id_list
.
append
(
obj
.
bebuild_src_id
)
parent_node
=
obj
.
bebuild_src_name
be_type
=
"build"
# Call the spell dictionary function
...
...
@@ -141,12 +137,12 @@ class BeDepend:
parent_node
,
be_type
)
if
obj
.
bebuild_src_name
not
in
self
.
source_name_set
:
self
.
source_name_set
.
add
(
obj
.
bebuild_src_name
)
source_id_list
.
append
(
obj
.
bebuild_src_id
)
if
obj
.
bin_name
:
# Determine if the bin package has been checked
if
obj
.
bin_name
not
in
self
.
bin_name_set
:
self
.
bin_name_set
.
add
(
obj
.
bin_name
)
bin_id_list
.
append
(
obj
.
bin_id
)
parent_node
=
obj
.
bin_name
be_type
=
"install"
# Call the spell dictionary function
...
...
@@ -156,6 +152,11 @@ class BeDepend:
obj
.
search_bin_version
,
parent_node
,
be_type
)
if
obj
.
bin_name
not
in
self
.
bin_name_set
:
self
.
bin_name_set
.
add
(
obj
.
bin_name
)
bin_id_list
.
append
(
obj
.
bin_id
)
# withsubpack=1
if
self
.
with_sub_pack
==
"1"
:
if
obj
.
install_depend_src_name
not
in
self
.
source_name_set
:
...
...
@@ -190,6 +191,7 @@ class BeDepend:
]
]
else
:
if
[
parent_node
,
be_type
]
not
in
self
.
result_dict
[
key
][
-
1
]:
self
.
result_dict
[
key
][
-
1
].
append
([
parent_node
,
be_type
...
...
packageship/test/common_files/correct_test_result_json/be_depend.json
0 → 100644
浏览文件 @
20de8b73
[
{
"input"
:
{
"packagename"
:
"A"
,
"dbname"
:
"openEuler-20.03-LTS"
},
"output"
:
{
"code"
:
"2001"
,
"data"
:
{
"A1"
:
[
"A"
,
"0.0.23b"
,
"openEuler-20.03-LTS"
,
[
[
"B"
,
"build"
],
[
"D"
,
"build"
],
[
"D1"
,
"install"
],
[
"B1"
,
"install"
]
]
],
"A2"
:
[
"A"
,
"0.0.23b"
,
"openEuler-20.03-LTS"
,
[
[
"C"
,
"build"
],
[
"C1"
,
"install"
],
[
"A1"
,
"install"
]
]
],
"A_src"
:
[
"source"
,
"0.0.23b"
,
"openEuler-20.03-LTS"
,
[
[
"root"
,
null
]
]
],
"B1"
:
[
"B"
,
"0.0.2"
,
"openEuler-20.03-LTS"
,
[
[
"A"
,
"build"
],
[
"D"
,
"build"
]
]
],
"B2"
:
[
"B"
,
"0.0.2"
,
"openEuler-20.03-LTS"
,
[
[
"C"
,
"build"
]
]
],
"C1"
:
[
"C"
,
"0.1"
,
"openEuler-20.03-LTS"
,
[
[
"A"
,
"build"
],
[
"B"
,
"build"
],
[
"A2"
,
"install"
],
[
"B2"
,
"install"
]
]
],
"D1"
:
[
"D"
,
"0.11"
,
"openEuler-20.03-LTS"
,
[
[
"D2"
,
"install"
],
[
"A2"
,
"install"
]
]
]
},
"msg"
:
"Successful Operation!"
}}
]
packageship/test/run_tests.py
浏览文件 @
20de8b73
...
...
@@ -9,9 +9,10 @@ def execute_operate():
# Import test cases and calls related to query database
from
test.test_module.dependent_query_tests.test_build_depend
import
test_build_depend_suit
from
test.test_module.packages_tests.test_packages
import
test_packages_suit
from
test.test_module.dependent_query_tests.test_be_depend
import
test_be_depend_suit
test_build_depend_suit
()
test_packages_suit
()
test_be_depend_suit
()
# Import test cases and calls related to the operation database
# like update database
...
...
packageship/test/test_module/dependent_query_tests/test_be_depend.py
0 → 100644
浏览文件 @
20de8b73
# -*- coding:utf-8 -*-
"""
Less transmission is always parameter transmission
"""
import
unittest
import
json
from
test.base_code.read_data_base
import
ReadTestBase
from
test.base_code.common_test_code
import
compare_two_values
,
get_correct_json_by_filename
from
packageship.application.apps.package.function.constants
import
ResponseCode
class
TestBeDepend
(
ReadTestBase
):
'''
The dependencies of the package are tested
'''
def
test_lack_parameter
(
self
):
"""
Less transmission is always parameter transmission
"""
# No arguments passed
resp
=
self
.
client
.
post
(
"/packages/findBeDepend"
,
data
=
'{}'
,
content_type
=
"application/json"
)
resp_dict
=
json
.
loads
(
resp
.
data
)
self
.
assertIn
(
"code"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
ResponseCode
.
PARAM_ERROR
,
resp_dict
.
get
(
"code"
),
msg
=
"Error in status code return"
)
self
.
assertIn
(
"msg"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
ResponseCode
.
CODE_MSG_MAP
.
get
(
ResponseCode
.
PARAM_ERROR
),
resp_dict
.
get
(
"msg"
),
msg
=
"Error in status code return"
)
self
.
assertIn
(
"data"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertIsNone
(
resp_dict
.
get
(
"data"
),
msg
=
"Error in data information return"
)
# Only the packagename
resp
=
self
.
client
.
post
(
"/packages/findBeDepend"
,
data
=
json
.
dumps
({
"packagename"
:
"CUnit"
,
}),
content_type
=
"application/json"
)
resp_dict
=
json
.
loads
(
resp
.
data
)
self
.
assertIn
(
"code"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
ResponseCode
.
PARAM_ERROR
,
resp_dict
.
get
(
"code"
),
msg
=
"Error in status code return"
)
self
.
assertIn
(
"msg"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
ResponseCode
.
CODE_MSG_MAP
.
get
(
ResponseCode
.
PARAM_ERROR
),
resp_dict
.
get
(
"msg"
),
msg
=
"Error in status code return"
)
self
.
assertIn
(
"data"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertIsNone
(
resp_dict
.
get
(
"data"
),
msg
=
"Error in data information return"
)
# Only the withsubpack
resp
=
self
.
client
.
post
(
"/packages/findBeDepend"
,
data
=
json
.
dumps
({
"withsubpack"
:
"0"
,
}),
content_type
=
"application/json"
)
resp_dict
=
json
.
loads
(
resp
.
data
)
self
.
assertIn
(
"code"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
ResponseCode
.
PARAM_ERROR
,
resp_dict
.
get
(
"code"
),
msg
=
"Error in status code return"
)
self
.
assertIn
(
"msg"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
ResponseCode
.
CODE_MSG_MAP
.
get
(
ResponseCode
.
PARAM_ERROR
),
resp_dict
.
get
(
"msg"
),
msg
=
"Error in status code return"
)
self
.
assertIn
(
"data"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertIsNone
(
resp_dict
.
get
(
"data"
),
msg
=
"Error in data information return"
)
# Only the dbname
resp
=
self
.
client
.
post
(
"/packages/findBeDepend"
,
data
=
json
.
dumps
({
"dbname"
:
"openEuler-20.03-LTS"
,
}),
content_type
=
"application/json"
)
resp_dict
=
json
.
loads
(
resp
.
data
)
self
.
assertIn
(
"code"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
ResponseCode
.
PARAM_ERROR
,
resp_dict
.
get
(
"code"
),
msg
=
"Error in status code return"
)
self
.
assertIn
(
"msg"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
ResponseCode
.
CODE_MSG_MAP
.
get
(
ResponseCode
.
PARAM_ERROR
),
resp_dict
.
get
(
"msg"
),
msg
=
"Error in status code return"
)
self
.
assertIn
(
"data"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertIsNone
(
resp_dict
.
get
(
"data"
),
msg
=
"Error in data information return"
)
# Don't preach withsubpack
resp
=
self
.
client
.
post
(
"/packages/findBeDepend"
,
data
=
json
.
dumps
({
"packagename"
:
"A"
,
"dbname"
:
"openEuler-20.03-LTS"
}),
content_type
=
"application/json"
)
resp_dict
=
json
.
loads
(
resp
.
data
)
self
.
assertIn
(
"code"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
ResponseCode
.
SUCCESS
,
resp_dict
.
get
(
"code"
),
msg
=
"Error in status code return"
)
self
.
assertIn
(
"msg"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
ResponseCode
.
CODE_MSG_MAP
.
get
(
ResponseCode
.
SUCCESS
),
resp_dict
.
get
(
"msg"
),
msg
=
"Error in status code return"
)
self
.
assertIn
(
"data"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertIsNotNone
(
resp_dict
.
get
(
"data"
),
msg
=
"Error in data information return"
)
# Don't preach dbname
resp
=
self
.
client
.
post
(
"/packages/findBeDepend"
,
data
=
json
.
dumps
({
"packagename"
:
"CUnit"
,
"withsubpack"
:
"0"
}),
content_type
=
"application/json"
)
resp_dict
=
json
.
loads
(
resp
.
data
)
self
.
assertIn
(
"code"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
ResponseCode
.
PARAM_ERROR
,
resp_dict
.
get
(
"code"
),
msg
=
"Error in status code return"
)
self
.
assertIn
(
"msg"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
ResponseCode
.
CODE_MSG_MAP
.
get
(
ResponseCode
.
PARAM_ERROR
),
resp_dict
.
get
(
"msg"
),
msg
=
"Error in status code return"
)
self
.
assertIn
(
"data"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertIsNone
(
resp_dict
.
get
(
"data"
),
msg
=
"Error in data information return"
)
# Don't preach packagename
resp
=
self
.
client
.
post
(
"/packages/findBeDepend"
,
data
=
json
.
dumps
({
"dbname"
:
"openEuler-20.03-LTS"
,
"withsubpack"
:
"0"
}),
content_type
=
"application/json"
)
resp_dict
=
json
.
loads
(
resp
.
data
)
self
.
assertIn
(
"code"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
ResponseCode
.
PARAM_ERROR
,
resp_dict
.
get
(
"code"
),
msg
=
"Error in status code return"
)
self
.
assertIn
(
"msg"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
ResponseCode
.
CODE_MSG_MAP
.
get
(
ResponseCode
.
PARAM_ERROR
),
resp_dict
.
get
(
"msg"
),
msg
=
"Error in status code return"
)
self
.
assertIn
(
"data"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertIsNone
(
resp_dict
.
get
(
"data"
),
msg
=
"Error in data information return"
)
# All incoming withsubpack=0
resp
=
self
.
client
.
post
(
"/packages/findBeDepend"
,
data
=
json
.
dumps
({
"packagename"
:
"A"
,
"dbname"
:
"openEuler-20.03-LTS"
,
"withsubpack"
:
"0"
}),
content_type
=
"application/json"
)
resp_dict
=
json
.
loads
(
resp
.
data
)
self
.
assertIn
(
"code"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
ResponseCode
.
SUCCESS
,
resp_dict
.
get
(
"code"
),
msg
=
"Error in status code return"
)
self
.
assertIn
(
"msg"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
ResponseCode
.
CODE_MSG_MAP
.
get
(
ResponseCode
.
SUCCESS
),
resp_dict
.
get
(
"msg"
),
msg
=
"Error in status code return"
)
self
.
assertIn
(
"data"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertIsNotNone
(
resp_dict
.
get
(
"data"
),
msg
=
"Error in data information return"
)
# All incoming withsubpack=1
resp
=
self
.
client
.
post
(
"/packages/findBeDepend"
,
data
=
json
.
dumps
({
"packagename"
:
"A"
,
"dbname"
:
"openEuler-20.03-LTS"
,
"withsubpack"
:
"1"
}),
content_type
=
"application/json"
)
resp_dict
=
json
.
loads
(
resp
.
data
)
self
.
assertIn
(
"code"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
ResponseCode
.
SUCCESS
,
resp_dict
.
get
(
"code"
),
msg
=
"Error in status code return"
)
self
.
assertIn
(
"msg"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
ResponseCode
.
CODE_MSG_MAP
.
get
(
ResponseCode
.
SUCCESS
),
resp_dict
.
get
(
"msg"
),
msg
=
"Error in status code return"
)
self
.
assertIn
(
"data"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertIsNotNone
(
resp_dict
.
get
(
"data"
),
msg
=
"Error in data information return"
)
def
test_wrong_parameter
(
self
):
"""
Parameter error
"""
# packagename Parameter error
resp
=
self
.
client
.
post
(
"/packages/findBeDepend"
,
data
=
json
.
dumps
({
"packagename"
:
"詹姆斯"
,
"dbname"
:
"openEuler-20.03-LTS"
,
"withsubpack"
:
"0"
}),
content_type
=
"application/json"
)
resp_dict
=
json
.
loads
(
resp
.
data
)
self
.
assertIn
(
"code"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
ResponseCode
.
PACK_NAME_NOT_FOUND
,
resp_dict
.
get
(
"code"
),
msg
=
"Error in status code return!"
)
self
.
assertIn
(
"msg"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
ResponseCode
.
CODE_MSG_MAP
.
get
(
ResponseCode
.
PACK_NAME_NOT_FOUND
),
resp_dict
.
get
(
"msg"
),
msg
=
"Error in status code return"
)
self
.
assertIn
(
"data"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertIsNone
(
resp_dict
.
get
(
"data"
),
msg
=
"Error in data information return"
)
# dbname Parameter error
resp
=
self
.
client
.
post
(
"/packages/findBeDepend"
,
data
=
json
.
dumps
({
"packagename"
:
"ATpy"
,
"dbname"
:
"asdfgjhk"
,
"withsubpack"
:
"0"
}),
content_type
=
"application/json"
)
resp_dict
=
json
.
loads
(
resp
.
data
)
self
.
assertIn
(
"code"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
ResponseCode
.
DB_NAME_ERROR
,
resp_dict
.
get
(
"code"
),
msg
=
"Error in status code return"
)
self
.
assertIn
(
"msg"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
ResponseCode
.
CODE_MSG_MAP
.
get
(
ResponseCode
.
DB_NAME_ERROR
),
resp_dict
.
get
(
"msg"
),
msg
=
"Error in status code return"
)
self
.
assertIn
(
"data"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertIsNone
(
resp_dict
.
get
(
"data"
),
msg
=
"Error in data information return"
)
# withsubpack Parameter error
resp
=
self
.
client
.
post
(
"/packages/findBeDepend"
,
data
=
json
.
dumps
({
"packagename"
:
"CUnit"
,
"dbname"
:
"openEuler-20.03-LTS"
,
"withsubpack"
:
"3"
}),
content_type
=
"application/json"
)
resp_dict
=
json
.
loads
(
resp
.
data
)
self
.
assertIn
(
"code"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
ResponseCode
.
PARAM_ERROR
,
resp_dict
.
get
(
"code"
),
msg
=
"Error in status code return"
)
self
.
assertIn
(
"msg"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertEqual
(
ResponseCode
.
CODE_MSG_MAP
.
get
(
ResponseCode
.
PARAM_ERROR
),
resp_dict
.
get
(
"msg"
),
msg
=
"Error in status code return"
)
self
.
assertIn
(
"data"
,
resp_dict
,
msg
=
"Error in data format return"
)
self
.
assertIsNone
(
resp_dict
.
get
(
"data"
),
msg
=
"Error in data information return"
)
def
test_true_params_result
(
self
):
"""
Results contrast
"""
correct_list
=
get_correct_json_by_filename
(
"be_depend"
)
self
.
assertNotEqual
([],
correct_list
,
msg
=
"Error reading JSON file"
)
for
correct_data
in
correct_list
:
input_value
=
correct_data
[
"input"
]
resp
=
self
.
client
.
post
(
"/packages/findBeDepend"
,
data
=
json
.
dumps
(
input_value
),
content_type
=
"application/json"
)
output_for_input
=
correct_data
[
"output"
]
resp_dict
=
json
.
loads
(
resp
.
data
)
self
.
assertTrue
(
compare_two_values
(
output_for_input
,
resp_dict
),
msg
=
"The answer is not correct"
)
def
test_be_depend_suit
():
"""
Start the test case function
"""
print
(
"---TestBeDepend START---"
)
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
TestBeDepend
(
"test_lack_parameter"
))
suite
.
addTest
(
TestBeDepend
(
"test_wrong_parameter"
))
suite
.
addTest
(
TestBeDepend
(
"test_true_params_result"
))
unittest
.
TextTestRunner
().
run
(
suite
)
# if __name__ == '__main__':
# unittest.main()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录