Fix API TEST for chart Version

Fix api test for chart b/c revert the api

Signed-off-by: DQ <dengq@vmware.com>
This commit is contained in:
DQ 2020-03-31 12:35:03 +08:00
parent 6216073d2a
commit cd69339014
2 changed files with 9 additions and 6 deletions

View File

@ -2,7 +2,7 @@ from __future__ import absolute_import
import unittest
from testutils import ADMIN_CLIENT
from testutils import ADMIN_CLIENT, CHART_API_CLIENT
from testutils import TEARDOWN
from library.user import User
from library.project import Project
@ -27,7 +27,7 @@ class TestProjects(unittest.TestCase):
@unittest.skipIf(TEARDOWN == False, "Test data won't be erased.")
def test_ClearData(self):
#1. Delete chart file;
self.chart.delete_chart_with_version(TestProjects.project_chart_name, TestProjects.CHART_NAME, TestProjects.VERSION, **ADMIN_CLIENT)
self.chart.delete_chart_with_version(TestProjects.project_chart_name, TestProjects.CHART_NAME, TestProjects.VERSION, **CHART_API_CLIENT)
#2. Delete project(PA);
self.project.delete_project(TestProjects.project_chart_id, **TestProjects.USER_CHART_CLIENT)
@ -50,8 +50,8 @@ class TestProjects(unittest.TestCase):
3. Delete user(UA).
"""
url = ADMIN_CLIENT["endpoint"]
user_chart_password = "Aa123456"
chart_api_url = CHART_API_CLIENT['endpoint']
user_chart_password = 'Aa123456'
TestProjects.CHART_NAME = 'mariadb'
TestProjects.VERSION = '4.3.1'
@ -60,14 +60,16 @@ class TestProjects(unittest.TestCase):
TestProjects.USER_CHART_CLIENT=dict(endpoint = url, username = user_chart_name, password = user_chart_password)
TestProjects.API_CHART_CLIENT=dict(endpoint = chart_api_url, username = user_chart_name, password = user_chart_password)
#2. Create a new project(PA) by user(UA);
TestProjects.project_chart_id, TestProjects.project_chart_name = self.project.create_project(metadata = {"public": "false"}, **TestProjects.USER_CHART_CLIENT)
#3. Upload a chart file to project(PA);
self.chart.upload_chart(TestProjects.project_chart_name, r'./tests/apitests/python/mariadb-{}.tgz'.format(TestProjects.VERSION), **TestProjects.USER_CHART_CLIENT)
self.chart.upload_chart(TestProjects.project_chart_name, r'./tests/apitests/python/mariadb-{}.tgz'.format(TestProjects.VERSION), **TestProjects.API_CHART_CLIENT)
#4. Chart file should be exist in project(PA).
self.chart.chart_should_exist(TestProjects.project_chart_name, TestProjects.CHART_NAME, **TestProjects.USER_CHART_CLIENT)
self.chart.chart_should_exist(TestProjects.project_chart_name, TestProjects.CHART_NAME, **TestProjects.API_CHART_CLIENT)
if __name__ == '__main__':
unittest.main()

View File

@ -14,6 +14,7 @@ admin_pwd = "Harbor12345"
harbor_server = os.environ["HARBOR_HOST"]
#CLIENT=dict(endpoint="https://"+harbor_server+"/api")
ADMIN_CLIENT=dict(endpoint = os.environ.get("HARBOR_HOST_SCHEMA", "https")+ "://"+harbor_server+"/api/v2.0", username = admin_user, password = admin_pwd)
CHART_API_CLIENT=dict(endpoint = os.environ.get("HARBOR_HOST_SCHEMA", "https")+ "://"+harbor_server+"/api", username = admin_user, password = admin_pwd)
USER_ROLE=dict(admin=0,normal=1)
TEARDOWN = os.environ.get('TEARDOWN', 'true').lower() in ('true', 'yes')