提交 c35716a7 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!74 修改test单元测试内容,以适配新的数据库结构和回显结构

Merge pull request !74 from tomtao/master
......@@ -75,7 +75,7 @@ class InstallDepend():
response_code: response code
Raises:
"""
result_list = self.__search_db.get_install_depend(self.__search_list)
result_list = set(self.__search_db.get_install_depend(self.__search_list))
for search in self.__search_list:
if search not in self.binary_dict.dictionary:
self.binary_dict.init_key(key=search, parent_node=[])
......
......@@ -64,7 +64,7 @@ class Log():
if path:
self.__path = os.path.join(LOG_FOLDER_PATH, path)
else:
self.__path = READCONFIG.get_system('log_path')
self.__path = READCONFIG.get_config('LOG', 'log_path')
if not self.__path:
self.__path = os.path.join(LOG_FOLDER_PATH, log_name)
else:
......
Name: pkgship
Version: 1.0
Release: 5
Version: 1.0.0
Release: 6
Summary: Pkgship implements rpm package dependence ,maintainer, patch query and so no.
License: Mulan 2.0
URL: https://gitee.com/openeuler/openEuler-Advisor
......@@ -8,6 +8,8 @@ Source0: https://gitee.com/openeuler/openEuler-Advisor/pkgship-%{version}
BuildArch: noarch
BuildRequires: python3-flask-restful python3-flask python3 python3-pyyaml python3-sqlalchemy
BuildRequires: python3-prettytable python3-requests python3-flask-session python3-flask-script python3-marshmallow
Requires: python3-pip python3-flask-restful python3-flask python3 python3-pyyaml
Requires: python3-sqlalchemy python3-prettytable python3-requests
Requires: python3-pyinstaller python3-flask-session python3-flask-script python3-marshmallow python3-uWSGI
......@@ -26,7 +28,11 @@ Pkgship implements rpm package dependence ,maintainer, patch query and so no.
%check
# change log_path to solve default log_path permission denied problem
log_path=`pwd`/tmp/
sed -i "/\[LOG\]/a\log_path=$log_path" test/common_files/package.ini
%{__python3} -m unittest test/run_tests.py
rm -rf $log_path
%post
#build cli bin
......@@ -61,6 +67,10 @@ rm -rf %{python3_sitelib}/packageship/build %{python3_sitelib}/packageship/dist
%changelog
* Wed Aug 12 2020 Zhang Tao <zhangtao306@huawei.com> - 1.0.0-6
- Fix the test content to adapt to the new data structure, add BuildRequires for running %check
* Mon Aug 10 2020 Zhengtang Gong <gongzhengtang@huawei.com> - 1.0-5
- Command line supports calling remote services
......
......@@ -34,8 +34,8 @@ class InitConf:
"data_{}_src.sqlite".format(str(index)))
bin_path = os.path.join(base_path, "db_origin",
"data_{}_bin.sqlite".format(str(index)))
obj["src_db_file"] = [src_path]
obj["bin_db_file"] = [bin_path]
obj["src_db_file"] = src_path
obj["bin_db_file"] = bin_path
with open(conf_path, 'w', encoding='utf-8') as w_f:
yaml.dump(origin_yaml, w_f)
......
- bin_db_file:
- C:\Users\14500\Desktop\workspace\openEuler_pkgmnt\openEuler_Advisor\packageship\test\common_files\db_origin\data_1_bin.sqlite
dbname: openEuler-20.03-LTS
- bin_db_file:
dbname: mainline
priority: 1
src_db_file:
- C:\Users\14500\Desktop\workspace\openEuler_pkgmnt\openEuler_Advisor\packageship\test\common_files\db_origin\data_1_src.sqlite
src_db_file:
status: enable
- bin_db_file:
- C:\Users\14500\Desktop\workspace\openEuler_pkgmnt\openEuler_Advisor\packageship\test\common_files\db_origin\data_2_bin.sqlite
dbname: openEuler-20.04-LTS
- bin_db_file:
dbname: fedora30
priority: 2
src_db_file:
- C:\Users\14500\Desktop\workspace\openEuler_pkgmnt\openEuler_Advisor\packageship\test\common_files\db_origin\data_2_src.sqlite
src_db_file:
status: enable
[
{
"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",
[
[
"input": {
"packagename": "A",
"dbname": "mainline"
},
"output": {
"code": "2001",
"data": {
"A1": [
"A",
"build"
"0.0.23b",
"mainline",
[
[
"B",
"build"
],
[
"D",
"build"
],
[
"D1",
"install"
],
[
"B1",
"install"
]
]
],
[
"D",
"build"
]
]
],
"B2": [
"B",
"0.0.2",
"openEuler-20.03-LTS",
[
[
"C",
"build"
]
]
],
"C1": [
"C",
"0.1",
"openEuler-20.03-LTS",
[
[
"A2": [
"A",
"build"
"0.0.23b",
"mainline",
[
[
"C",
"build"
],
[
"C1",
"install"
],
[
"A1",
"install"
]
]
],
[
"A_src": [
"source",
"0.0.23b",
"mainline",
[
[
"root",
null
]
]
],
"B1": [
"B",
"build"
"0.0.2",
"mainline",
[
[
"A",
"build"
],
[
"D",
"build"
]
]
],
[
"A2",
"install"
"B2": [
"B",
"0.0.2",
"mainline",
[
[
"C",
"build"
]
]
],
[
"B2",
"install"
]
]
],
"D1": [
"D",
"0.11",
"openEuler-20.03-LTS",
[
[
"D2",
"install"
"C1": [
"C",
"0.1",
"mainline",
[
[
"A",
"build"
],
[
"B",
"build"
],
[
"A2",
"install"
],
[
"B2",
"install"
]
]
],
[
"A2",
"install"
"D1": [
"D",
"0.11",
"mainline",
[
[
"D2",
"install"
],
[
"A2",
"install"
]
]
]
]
]
},
"msg": "Successful Operation!"
}}
]
},
"msg": "Successful Operation!"
}
}
]
\ No newline at end of file
......@@ -9,7 +9,7 @@
"A_src": [
"source",
"0.0.23b",
"openEuler-20.03-LTS",
"mainline",
[
[
"root",
......@@ -20,7 +20,7 @@
"B1": [
"B",
"0.0.2",
"openEuler-20.03-LTS",
"mainline",
[
[
"A",
......@@ -31,7 +31,7 @@
"C1": [
"C",
"0.1",
"openEuler-20.03-LTS",
"mainline",
[
[
"A",
......@@ -46,7 +46,7 @@
"A1": [
"A",
"0.0.23b",
"openEuler-20.03-LTS",
"mainline",
[
[
"B1",
......@@ -61,7 +61,7 @@
"A2": [
"A",
"0.0.23b",
"openEuler-20.03-LTS",
"mainline",
[
[
"A1",
......@@ -76,7 +76,7 @@
"D1": [
"D",
"0.11",
"openEuler-20.03-LTS",
"mainline",
[
[
"A2",
......
[{
"database_name": "openEuler-20.03-LTS",
"priority": 1,
"status": "enable"
}, {
"database_name": "openEuler-20.04-LTS",
"priority": 2,
"status": "enable"
}]
\ No newline at end of file
[
{
"database_name": "mainline",
"priority": 1,
"status": "enable"
},
{
"database_name": "fedora30",
"priority": 2,
"status": "enable"
}
]
\ No newline at end of file
[{
"buildDep": ["B1", "C1"],
"dbname": "openEuler-20.03-LTS",
"downloadURL": null,
"license": "GPLv2+ and BSD and MIT and IBM",
"maintainer": null,
"maintainlevel": null,
"sourceName": "A",
"sourceURL": "http://play0ad.com",
"subpack": {
"A1": ["A2"],
"A2": ["C1", "D1"]
},
"version": "0.0.23b"
}]
\ No newline at end of file
[
{
"url": "/packages/packageInfo?sourceName=A&dbName=mainline",
"data": [
{
"buildDep": [
"B1",
"C1"
],
"dbname": "mainline",
"license": "GPLv2+ and BSD and MIT and IBM",
"maintainer": null,
"maintainlevel": null,
"rpm_packager": "Fedora Project",
"sourceName": "A",
"sourceURL": "http://play0ad.com",
"subpack": {
"A1": [
"A2"
],
"A2": [
"C1",
"D1"
]
},
"version": "0.0.23b"
}
]
}
]
\ No newline at end of file
......@@ -9,7 +9,7 @@
"A1": [
"A",
"0.0.23b",
"openEuler-20.03-LTS",
"mainline",
[
[
"root",
......@@ -24,7 +24,7 @@
"A2": [
"A",
"0.0.23b",
"openEuler-20.03-LTS",
"mainline",
[
[
"A1",
......@@ -39,7 +39,7 @@
"C1": [
"C",
"0.1",
"openEuler-20.03-LTS",
"mainline",
[
[
"A2",
......@@ -50,7 +50,7 @@
"D1": [
"D",
"0.11",
"openEuler-20.03-LTS",
"mainline",
[
[
"A2",
......@@ -72,7 +72,7 @@
"A1": [
"A",
"0.0.23b",
"openEuler-20.03-LTS",
"mainline",
[
[
"D1",
......@@ -83,7 +83,7 @@
"A2": [
"A",
"0.0.23b",
"openEuler-20.03-LTS",
"mainline",
[
[
"A1",
......@@ -98,7 +98,7 @@
"C1": [
"C",
"0.1",
"openEuler-20.03-LTS",
"mainline",
[
[
"A2",
......@@ -109,7 +109,7 @@
"D1": [
"D",
"0.11",
"openEuler-20.03-LTS",
"mainline",
[
[
"D2",
......@@ -124,7 +124,7 @@
"D2": [
"D",
"0.11",
"openEuler-20.03-LTS",
"mainline",
[
[
"root",
......@@ -146,7 +146,7 @@
"C2": [
"C",
"0.1",
"openEuler-20.03-LTS",
"mainline",
[
[
"root",
......
[{
"dbname": "openEuler-20.03-LTS",
"dbname": "mainline",
"downloadURL": null,
"license": "GPLv2+ and BSD and MIT and IBM",
"maintainer": null,
......@@ -8,7 +8,7 @@
"sourceURL": "http://play0ad.com",
"version": "0.0.23b"
}, {
"dbname": "openEuler-20.03-LTS",
"dbname": "mainline",
"downloadURL": null,
"license": null,
"maintainer": null,
......@@ -17,7 +17,7 @@
"sourceURL": null,
"version": "0.0.2"
}, {
"dbname": "openEuler-20.03-LTS",
"dbname": "mainline",
"downloadURL": null,
"license": null,
"maintainer": null,
......@@ -26,7 +26,7 @@
"sourceURL": null,
"version": "0.1"
}, {
"dbname": "openEuler-20.03-LTS",
"dbname": "mainline",
"downloadURL": null,
"license": null,
"maintainer": null,
......@@ -35,7 +35,7 @@
"sourceURL": null,
"version": "0.11"
}, {
"dbname": "openEuler-20.04-LTS",
"dbname": "fedora30",
"downloadURL": null,
"license": "GPLv2+ and BSD and MIT and IBM",
"maintainer": null,
......@@ -44,7 +44,7 @@
"sourceURL": "http://play0ad.com",
"version": "0.0.23b"
}, {
"dbname": "openEuler-20.04-LTS",
"dbname": "fedora30",
"downloadURL": null,
"license": null,
"maintainer": null,
......@@ -53,7 +53,7 @@
"sourceURL": null,
"version": "0.0.3"
}, {
"dbname": "openEuler-20.04-LTS",
"dbname": "fedora30",
"downloadURL": null,
"license": null,
"maintainer": null,
......@@ -62,7 +62,7 @@
"sourceURL": null,
"version": "0.1"
}, {
"dbname": "openEuler-20.04-LTS",
"dbname": "fedora30",
"downloadURL": null,
"license": null,
"maintainer": null,
......@@ -71,7 +71,7 @@
"sourceURL": null,
"version": "0.12"
}, {
"dbname": "openEuler-20.04-LTS",
"dbname": "fedora30",
"downloadURL": null,
"license": null,
"maintainer": null,
......@@ -80,7 +80,7 @@
"sourceURL": null,
"version": "0.4"
}, {
"dbname": "openEuler-20.04-LTS",
"dbname": "fedora30",
"downloadURL": null,
"license": null,
"maintainer": null,
......
......@@ -10,7 +10,7 @@
"A1": [
"A",
"0.0.23b",
"openEuler-20.03-LTS",
"mainline",
[
[
"root",
......@@ -33,7 +33,7 @@
"A2": [
"A",
"0.0.23b",
"openEuler-20.03-LTS",
"mainline",
[
[
"A1",
......@@ -52,7 +52,7 @@
"B1": [
"B",
"0.0.2",
"openEuler-20.03-LTS",
"mainline",
[
[
"A",
......@@ -67,7 +67,7 @@
"B2": [
"B",
"0.0.2",
"openEuler-20.03-LTS",
"mainline",
[
[
"C",
......@@ -78,7 +78,7 @@
"C1": [
"C",
"0.1",
"openEuler-20.03-LTS",
"mainline",
[
[
"A",
......@@ -97,7 +97,7 @@
"D1": [
"D",
"0.11",
"openEuler-20.03-LTS",
"mainline",
[
[
"A2",
......@@ -108,15 +108,19 @@
},
"source_dicts": {
"A": [
"openEuler-20.03-LTS",
"mainline",
"0.0.23b"
],
"B": [
"mainline",
"0.0.2"
],
"C": [
"openEuler-20.03-LTS",
"mainline",
"0.1"
],
"D": [
"openEuler-20.03-LTS",
"mainline",
"0.11"
]
}
......@@ -136,7 +140,7 @@
"A1": [
"A",
"0.0.23b",
"openEuler-20.03-LTS",
"mainline",
[
[
"D1",
......@@ -155,7 +159,7 @@
"A2": [
"A",
"0.0.23b",
"openEuler-20.03-LTS",
"mainline",
[
[
"C1",
......@@ -174,7 +178,7 @@
"B1": [
"B",
"0.0.2",
"openEuler-20.03-LTS",
"mainline",
[
[
"A",
......@@ -189,7 +193,7 @@
"B2": [
"B",
"0.0.2",
"openEuler-20.03-LTS",
"mainline",
[
[
"C",
......@@ -200,7 +204,7 @@
"C1": [
"C",
"0.1",
"openEuler-20.03-LTS",
"mainline",
[
[
"root",
......@@ -223,7 +227,7 @@
"C2": [
"C",
"0.1",
"openEuler-20.03-LTS",
"mainline",
[
[
"root",
......@@ -234,7 +238,7 @@
"D1": [
"D",
"0.11",
"openEuler-20.03-LTS",
"mainline",
[
[
"A2",
......@@ -245,15 +249,19 @@
},
"source_dicts": {
"A": [
"openEuler-20.03-LTS",
"mainline",
"0.0.23b"
],
"B": [
"mainline",
"0.0.2"
],
"C": [
"openEuler-20.03-LTS",
"mainline",
"0.1"
],
"D": [
"openEuler-20.03-LTS",
"mainline",
"0.11"
]
}
......@@ -274,7 +282,7 @@
"A1": [
"A",
"0.0.23b",
"openEuler-20.03-LTS",
"mainline",
[
[
"D1",
......@@ -293,7 +301,7 @@
"A2": [
"A",
"0.0.23b",
"openEuler-20.03-LTS",
"mainline",
[
[
"root",
......@@ -316,7 +324,7 @@
"B1": [
"B",
"0.0.2",
"openEuler-20.03-LTS",
"mainline",
[
[
"A",
......@@ -331,7 +339,7 @@
"B2": [
"B",
"0.0.2",
"openEuler-20.03-LTS",
"mainline",
[
[
"C",
......@@ -342,7 +350,7 @@
"C1": [
"C",
"0.1",
"openEuler-20.03-LTS",
"mainline",
[
[
"A2",
......@@ -361,7 +369,7 @@
"D1": [
"D",
"0.11",
"openEuler-20.03-LTS",
"mainline",
[
[
"A2",
......@@ -376,7 +384,7 @@
"C2": [
"C",
"0.1",
"openEuler-20.03-LTS",
"mainline",
[
[
"C",
......@@ -387,7 +395,7 @@
"D2": [
"D",
"0.11",
"openEuler-20.03-LTS",
"mainline",
[
[
"D",
......@@ -398,19 +406,19 @@
},
"source_dicts": {
"A": [
"openEuler-20.03-LTS",
"mainline",
"0.0.23b"
],
"B": [
"openEuler-20.03-LTS",
"mainline",
"0.0.2"
],
"C": [
"openEuler-20.03-LTS",
"mainline",
"0.1"
],
"D": [
"openEuler-20.03-LTS",
"mainline",
"0.11"
]
}
......@@ -432,7 +440,7 @@
"A1": [
"A",
"0.0.23b",
"openEuler-20.03-LTS",
"mainline",
[
[
"root",
......@@ -455,7 +463,7 @@
"A2": [
"A",
"0.0.23b",
"openEuler-20.03-LTS",
"mainline",
[
[
"root",
......@@ -478,7 +486,7 @@
"B1": [
"B",
"0.0.2",
"openEuler-20.03-LTS",
"mainline",
[
[
"A",
......@@ -493,7 +501,7 @@
"B2": [
"B",
"0.0.2",
"openEuler-20.03-LTS",
"mainline",
[
[
"C",
......@@ -504,7 +512,7 @@
"C1": [
"C",
"0.1",
"openEuler-20.03-LTS",
"mainline",
[
[
"A2",
......@@ -523,7 +531,7 @@
"D1": [
"D",
"0.11",
"openEuler-20.03-LTS",
"mainline",
[
[
"A2",
......@@ -538,7 +546,7 @@
"C2": [
"C",
"0.1",
"openEuler-20.03-LTS",
"mainline",
[
[
"C",
......@@ -549,7 +557,7 @@
"D2": [
"D",
"0.11",
"openEuler-20.03-LTS",
"mainline",
[
[
"D",
......@@ -560,19 +568,19 @@
},
"source_dicts": {
"A": [
"openEuler-20.03-LTS",
"mainline",
"0.0.23b"
],
"B": [
"openEuler-20.03-LTS",
"mainline",
"0.0.2"
],
"C": [
"openEuler-20.03-LTS",
"mainline",
"0.1"
],
"D": [
"openEuler-20.03-LTS",
"mainline",
"0.11"
]
}
......@@ -594,7 +602,7 @@
"A1": [
"A",
"0.0.23b",
"openEuler-20.03-LTS",
"mainline",
[
[
"root",
......@@ -621,7 +629,7 @@
"A2": [
"A",
"0.0.23b",
"openEuler-20.03-LTS",
"mainline",
[
[
"root",
......@@ -644,7 +652,7 @@
"B1": [
"B",
"0.0.2",
"openEuler-20.03-LTS",
"mainline",
[
[
"A",
......@@ -659,7 +667,7 @@
"B2": [
"B",
"0.0.2",
"openEuler-20.03-LTS",
"mainline",
[
[
"C",
......@@ -670,7 +678,7 @@
"C1": [
"C",
"0.1",
"openEuler-20.03-LTS",
"mainline",
[
[
"A2",
......@@ -693,7 +701,7 @@
"D1": [
"D",
"0.11",
"openEuler-20.03-LTS",
"mainline",
[
[
"A2",
......@@ -708,7 +716,7 @@
"C2": [
"C",
"0.1",
"openEuler-20.03-LTS",
"mainline",
[
[
"C",
......@@ -719,7 +727,7 @@
"D2": [
"D",
"0.11",
"openEuler-20.03-LTS",
"mainline",
[
[
"D",
......@@ -730,19 +738,19 @@
},
"source_dicts": {
"A": [
"openEuler-20.03-LTS",
"mainline",
"0.0.23b"
],
"B": [
"openEuler-20.03-LTS",
"mainline",
"0.0.2"
],
"C": [
"openEuler-20.03-LTS",
"mainline",
"0.1"
],
"D": [
"openEuler-20.03-LTS",
"mainline",
"0.11"
]
}
......@@ -763,7 +771,7 @@
"A1": [
"A",
"0.0.23b",
"openEuler-20.03-LTS",
"mainline",
[
[
"D1",
......@@ -786,7 +794,7 @@
"A2": [
"A",
"0.0.23b",
"openEuler-20.03-LTS",
"mainline",
[
[
"root",
......@@ -809,7 +817,7 @@
"B1": [
"B",
"0.0.2",
"openEuler-20.03-LTS",
"mainline",
[
[
"A",
......@@ -824,7 +832,7 @@
"B2": [
"B",
"0.0.2",
"openEuler-20.03-LTS",
"mainline",
[
[
"C",
......@@ -835,7 +843,7 @@
"C1": [
"C",
"0.1",
"openEuler-20.03-LTS",
"mainline",
[
[
"A2",
......@@ -858,7 +866,7 @@
"D1": [
"D",
"0.11",
"openEuler-20.03-LTS",
"mainline",
[
[
"A2",
......@@ -869,19 +877,19 @@
},
"source_dicts": {
"A": [
"openEuler-20.03-LTS",
"mainline",
"0.0.23b"
],
"B": [
"openEuler-20.03-LTS",
"mainline",
"0.0.2"
],
"C": [
"openEuler-20.03-LTS",
"mainline",
"0.1"
],
"D": [
"openEuler-20.03-LTS",
"mainline",
"0.11"
]
}
......@@ -903,7 +911,7 @@
"A1": [
"A",
"0.0.23b",
"openEuler-20.03-LTS",
"mainline",
[
[
"root",
......@@ -930,7 +938,7 @@
"A2": [
"A",
"0.0.23b",
"openEuler-20.03-LTS",
"mainline",
[
[
"root",
......@@ -953,7 +961,7 @@
"B1": [
"B",
"0.0.2",
"openEuler-20.03-LTS",
"mainline",
[
[
"A",
......@@ -968,7 +976,7 @@
"B2": [
"B",
"0.0.2",
"openEuler-20.03-LTS",
"mainline",
[
[
"C",
......@@ -979,7 +987,7 @@
"C1": [
"C",
"0.1",
"openEuler-20.03-LTS",
"mainline",
[
[
"A2",
......@@ -1002,7 +1010,7 @@
"D1": [
"D",
"0.11",
"openEuler-20.03-LTS",
"mainline",
[
[
"A2",
......@@ -1013,19 +1021,19 @@
},
"source_dicts": {
"A": [
"openEuler-20.03-LTS",
"mainline",
"0.0.23b"
],
"B": [
"openEuler-20.03-LTS",
"mainline",
"0.0.2"
],
"C": [
"openEuler-20.03-LTS",
"mainline",
"0.1"
],
"D": [
"openEuler-20.03-LTS",
"mainline",
"0.11"
]
}
......
- database_name: openEuler-20.03-LTS
- database_name: mainline
priority: 1
status: enable
- database_name: openEuler-20.04-LTS
- database_name: fedora30
priority: 2
status: enable
[SYSTEM]
init_conf_path = C:\Users\14500\Desktop\workspace\openEuler_pkgmnt\openEuler_Advisor\packageship\test\common_files\conf.yaml
init_conf_path =
debug = false
write_port = 8080
query_port = 8090
......@@ -7,10 +7,10 @@ write_ip_addr = 127.0.0.1
query_ip_addr = 127.0.0.1
[DATABASE]
user_name = root
password = 123456
host = localhost
port = 3306
user_name =
password =
host =
port =
database =
dbtype = sqlite
......@@ -19,6 +19,8 @@ log_level = INFO
log_name = log_info.log
[UWSGI]
daemonize = /var/run/pkgship/uwsgi.log
daemonize = /var/log/uwsgi.log
buffer-size = 65536
http-timeout = 600
harakiri = 600
......@@ -8,13 +8,13 @@ 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
from packageship.application.apps.package.function.searchdb import db_priority
class TestBeDepend(ReadTestBase):
"""
The dependencies of the package are tested
"""
db_name = db_priority()[0]
def test_lack_parameter(self):
"""
Less transmission is always parameter transmission
......@@ -98,7 +98,7 @@ class TestBeDepend(ReadTestBase):
# Only the dbname
resp = self.client.post("/packages/findBeDepend",
data=json.dumps({
"dbname": "openEuler-20.03-LTS",
"dbname": f"{self.db_name}",
}),
content_type="application/json")
......@@ -125,7 +125,7 @@ class TestBeDepend(ReadTestBase):
resp = self.client.post("/packages/findBeDepend",
data=json.dumps({
"packagename": "A",
"dbname": "openEuler-20.03-LTS"
"dbname": f"{self.db_name}"
}),
content_type="application/json")
......@@ -176,7 +176,7 @@ class TestBeDepend(ReadTestBase):
# Don't preach packagename
resp = self.client.post("/packages/findBeDepend",
data=json.dumps({
"dbname": "openEuler-20.03-LTS",
"dbname": f"{self.db_name}",
"withsubpack": "0"
}),
content_type="application/json")
......@@ -204,7 +204,7 @@ class TestBeDepend(ReadTestBase):
resp = self.client.post("/packages/findBeDepend",
data=json.dumps({
"packagename": "A",
"dbname": "openEuler-20.03-LTS",
"dbname": f"{self.db_name}",
"withsubpack": "0"
}),
content_type="application/json")
......@@ -230,7 +230,7 @@ class TestBeDepend(ReadTestBase):
resp = self.client.post("/packages/findBeDepend",
data=json.dumps({
"packagename": "A",
"dbname": "openEuler-20.03-LTS",
"dbname": f"{self.db_name}",
"withsubpack": "1"
}),
content_type="application/json")
......@@ -261,7 +261,7 @@ class TestBeDepend(ReadTestBase):
resp = self.client.post("/packages/findBeDepend",
data=json.dumps({
"packagename": "詹姆斯",
"dbname": "openEuler-20.03-LTS",
"dbname": f"{self.db_name}",
"withsubpack": "0"
}),
content_type="application/json")
......@@ -316,7 +316,7 @@ class TestBeDepend(ReadTestBase):
resp = self.client.post("/packages/findBeDepend",
data=json.dumps({
"packagename": "CUnit",
"dbname": "openEuler-20.03-LTS",
"dbname": f"{self.db_name}",
"withsubpack": "3"
}),
content_type="application/json")
......
......@@ -280,7 +280,10 @@ class TestSelfDepend(ReadTestBase):
data=json.dumps(input_value),
content_type="application/json")
output_for_input = correct_data["output"]
from pprint import pprint
resp_dict = json.loads(resp.data)
self.assertTrue(compare_two_values(output_for_input, resp_dict),
msg="The answer is not correct")
......
......@@ -71,7 +71,7 @@ class TestDeleteRepodatas(OperateTestBase):
try:
shutil.copyfile(system_config.DATABASE_FILE_INFO, system_config.DATABASE_FILE_INFO + '.bak')
shutil.copytree(system_config.DATABASE_FOLDER_PATH, system_config.DATABASE_FOLDER_PATH + '.bak')
resp = self.client.delete("/repodatas?dbName=openEuler-20.04-LTS")
resp = self.client.delete("/repodatas?dbName=fedora30")
resp_dict = json.loads(resp.data)
self.assertIn("code", resp_dict, msg="Error in data format return")
......
......@@ -10,19 +10,18 @@ import unittest
import json
from packageship.application.apps.package.function.constants import ResponseCode
from packageship.application.apps.package.function.searchdb import db_priority
class TestGetSinglePack(ReadTestBase):
"""
Single package test case
"""
db_name = db_priority()[-1]
def test_error_sourcename(self):
"""sourceName is none or err"""
resp = self.client.get("packages/findByPackName?dbName=openeuler-20.03-lts")
resp = self.client.get(f"packages/packageInfo?dbName={self.db_name}")
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"),
......@@ -41,7 +40,7 @@ class TestGetSinglePack(ReadTestBase):
msg="Error in data information return")
resp = self.client.get(
"packages/findByPackName?sourceName=&dbName=openEuler-20.03-LTS")
f"packages/packageInfo?sourceName=&dbName={self.db_name}")
resp_dict = json.loads(resp.data)
self.assertIn("code", resp_dict, msg="Error in data format return")
......@@ -62,7 +61,7 @@ class TestGetSinglePack(ReadTestBase):
msg="Error in data information return")
resp = self.client.get(
"packages/findByPackName?sourceName=test&dbName=for")
"packages/packageInfo?sourceName=test&dbName=for")
resp_dict = json.loads(resp.data)
self.assertIn("code", resp_dict, msg="Error in data format return")
......@@ -85,7 +84,7 @@ class TestGetSinglePack(ReadTestBase):
def test_true_dbname(self):
"""dbName is null or err"""
resp = self.client.get("packages/findByPackName?sourceName=A")
resp = self.client.get("packages/packageInfo?sourceName=A")
resp_dict = json.loads(resp.data)
self.assertIn("code", resp_dict, msg="Error in data format return")
......@@ -105,10 +104,10 @@ class TestGetSinglePack(ReadTestBase):
correct_list = get_correct_json_by_filename("get_single_package")
self.assertNotEqual([], correct_list, msg="Error reading JSON file")
input_value = correct_list[0]["url"]
resp = self.client.get(
"/packages/findByPackName?sourceName=A&dbName=openEuler-20.03-LTS")
f"{input_value}")
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"),
......@@ -123,13 +122,13 @@ class TestGetSinglePack(ReadTestBase):
self.assertTrue(
compare_two_values(
resp_dict.get("data"),
correct_list),
correct_list[0]['data']),
msg="Error in data information return")
def test_wrong_dbname(self):
"""test_wrong_dbname"""
resp = self.client.get(
"/packages/findByPackName?sourceName=CUnit&dbName=openEuler-20.03-lts")
"/packages/packageInfo?sourceName=A&dbName=open")
resp_dict = json.loads(resp.data)
self.assertIn("code", resp_dict, msg="Error in data format return")
......
......@@ -6,15 +6,15 @@ import unittest
import json
from packageship.application.apps.package.function.constants import ResponseCode
from packageship.application.apps.package.function.searchdb import db_priority
class TestUpdatePackage(OperateTestBase):
"""TestUpdatePackage"""
db_name = db_priority()[0]
def test_empty_dbname(self):
"""Parameter error"""
resp = self.client.put("/packages/findByPackName",
resp = self.client.put("/packages/packageInfo",
data=json.dumps({"dbName": "",
"sourceName": "xx",
"maintainer": "",
......@@ -41,8 +41,8 @@ class TestUpdatePackage(OperateTestBase):
msg="Error in data information return")
# wrong dbname
resp = self.client.put("/packages/findByPackName",
data=json.dumps({"dbName": "xx",
resp = self.client.put("/packages/packageInfo",
data=json.dumps({"dbName": "xhhz",
"sourceName": "xx",
"maintainer": "",
"maintainlevel": "1"}),
......@@ -70,8 +70,8 @@ class TestUpdatePackage(OperateTestBase):
def test_empty_sourcename(self):
"""Parameter error"""
resp = self.client.put("/packages/findByPackName",
data=json.dumps({"dbName": "openEuler-20.04-LTS",
resp = self.client.put("/packages/packageInfo",
data=json.dumps({"dbName": f"{self.db_name}",
"sourceName": "xx",
"maintainer": "1"}),
content_type="application/json")
......@@ -95,8 +95,8 @@ class TestUpdatePackage(OperateTestBase):
resp_dict.get("data"),
msg="Error in data information return")
# miss maintainer maintainlevel
resp = self.client.put("/packages/findByPackName",
data=json.dumps({"dbName": "openEuler-20.04-LTS",
resp = self.client.put("/packages/packageInfo",
data=json.dumps({"dbName": f"{self.db_name}",
"sourceName": "xx"}),
content_type="application/json")
resp_dict = json.loads(resp.data)
......@@ -123,8 +123,8 @@ class TestUpdatePackage(OperateTestBase):
"""
Returns:
"""
resp = self.client.put("/packages/findByPackName",
data=json.dumps({"dbName": "openEuler-20.04-LTS",
resp = self.client.put("/packages/packageInfo",
data=json.dumps({"dbName": f"{self.db_name}",
"sourceName": "A",
"maintainer": "x",
"maintainlevel": "1"}),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册