forked from beimingwu/beimingwu
fix(backend): fix bugs in UpdateLearnwareApi
This commit is contained in:
parent
e0dcc6e940
commit
f6ea4f1972
|
@ -192,7 +192,7 @@ class UpdateLearnwareApi(flask_restful.Resource):
|
|||
if context.engine.get_learnware_by_ids(learnware_id) is not None:
|
||||
context.engine.update_learnware(
|
||||
id=learnware_id,
|
||||
zip_path=learnware_file,
|
||||
zip_path=learnware_path,
|
||||
semantic_spec=semantic_specification,
|
||||
checker_names=[],
|
||||
check_status=EasySemanticChecker.NONUSABLE_LEARNWARE,
|
||||
|
|
|
@ -40,106 +40,108 @@ class TestUser(unittest.TestCase):
|
|||
TestUser.server_process.kill()
|
||||
pass
|
||||
|
||||
# def test_profile(self):
|
||||
# headers = testops.login(TestUser.email, TestUser.password)
|
||||
# result = testops.url_request("user/profile", {}, headers=headers)
|
||||
def test_profile(self):
|
||||
headers = testops.login(TestUser.email, TestUser.password)
|
||||
result = testops.url_request("user/profile", {}, headers=headers)
|
||||
|
||||
# self.assertEqual(result["code"], 0)
|
||||
# self.assertEqual(result["data"]["username"], TestUser.username)
|
||||
# pass
|
||||
self.assertEqual(result["code"], 0)
|
||||
self.assertEqual(result["data"]["username"], TestUser.username)
|
||||
pass
|
||||
|
||||
# def test_change_password(self):
|
||||
# headers = testops.login(TestUser.email, TestUser.password)
|
||||
# result = testops.url_request(
|
||||
# "user/change_password", {"old_password": TestUser.password, "new_password": "test2"}, headers=headers
|
||||
# )
|
||||
def test_change_password(self):
|
||||
headers = testops.login(TestUser.email, TestUser.password)
|
||||
result = testops.url_request(
|
||||
"user/change_password", {"old_password": TestUser.password, "new_password": "test2"}, headers=headers
|
||||
)
|
||||
|
||||
# self.assertEqual(result["code"], 0)
|
||||
self.assertEqual(result["code"], 0)
|
||||
|
||||
# result = testops.url_request("auth/logout", {}, headers=headers)
|
||||
result = testops.url_request("auth/logout", {}, headers=headers)
|
||||
|
||||
# self.assertEqual(result["code"], 0)
|
||||
self.assertEqual(result["code"], 0)
|
||||
|
||||
# headers = testops.login(TestUser.email, "test2")
|
||||
headers = testops.login(TestUser.email, "test2")
|
||||
|
||||
# result = testops.url_request(
|
||||
# "user/change_password", {"old_password": "test2", "new_password": TestUser.password}, headers=headers
|
||||
# )
|
||||
result = testops.url_request(
|
||||
"user/change_password", {"old_password": "test2", "new_password": TestUser.password}, headers=headers
|
||||
)
|
||||
|
||||
# self.assertEqual(result["code"], 0)
|
||||
self.assertEqual(result["code"], 0)
|
||||
|
||||
# pass
|
||||
pass
|
||||
|
||||
# def test_list_learnware(self):
|
||||
# headers = testops.login(TestUser.email, TestUser.password)
|
||||
# semantic_specification = testops.test_learnware_semantic_specification()
|
||||
def test_list_learnware(self):
|
||||
headers = testops.login(TestUser.email, TestUser.password)
|
||||
semantic_specification = testops.test_learnware_semantic_specification()
|
||||
|
||||
# learnware_file = open(os.path.join("tests", "data", "test_learnware.zip"), "rb")
|
||||
# files = {"learnware_file": learnware_file}
|
||||
learnware_file = open(os.path.join("tests", "data", "test_learnware.zip"), "rb")
|
||||
files = {"learnware_file": learnware_file}
|
||||
|
||||
# # print(semantic_specification)
|
||||
# result = testops.url_request(
|
||||
# "user/add_learnware",
|
||||
# {"semantic_specification": json.dumps(semantic_specification)},
|
||||
# files=files,
|
||||
# headers=headers,
|
||||
# )
|
||||
# print(semantic_specification)
|
||||
result = testops.url_request(
|
||||
"user/add_learnware",
|
||||
{"semantic_specification": json.dumps(semantic_specification)},
|
||||
files=files,
|
||||
headers=headers,
|
||||
)
|
||||
|
||||
# learnware_file.close()
|
||||
# self.assertEqual(result["code"], 0)
|
||||
# learnware_id = result["data"]["learnware_id"]
|
||||
learnware_file.close()
|
||||
self.assertEqual(result["code"], 0)
|
||||
learnware_id = result["data"]["learnware_id"]
|
||||
|
||||
# self.assertTrue(os.path.exists(context.get_learnware_verify_file_path(learnware_id)))
|
||||
self.assertTrue(os.path.exists(context.get_learnware_verify_file_path(learnware_id)))
|
||||
|
||||
# result = testops.url_request("user/list_learnware", {"page": 0, "limit": 10}, headers=headers)
|
||||
result = testops.url_request("user/list_learnware", {"page": 0, "limit": 10}, headers=headers)
|
||||
|
||||
# self.assertEqual(result["code"], 0)
|
||||
# self.assertEqual(result["data"]["total_pages"], 1)
|
||||
# self.assertEqual(result["data"]["learnware_list"][0]["learnware_id"], learnware_id)
|
||||
self.assertEqual(result["code"], 0)
|
||||
self.assertEqual(result["data"]["total_pages"], 1)
|
||||
self.assertEqual(result["data"]["learnware_list"][0]["learnware_id"], learnware_id)
|
||||
|
||||
# testops.add_learnware_to_engine(learnware_id, headers)
|
||||
testops.add_learnware_to_engine(learnware_id, headers)
|
||||
|
||||
# result = testops.url_request("user/list_learnware", {"page": 0, "limit": 10}, headers=headers)
|
||||
result = testops.url_request("user/list_learnware", {"page": 0, "limit": 10}, headers=headers)
|
||||
|
||||
# self.assertEqual(result["code"], 0)
|
||||
# self.assertEqual(result["data"]["total_pages"], 1)
|
||||
# self.assertEqual(result["data"]["learnware_list"][0]["learnware_id"], learnware_id)
|
||||
self.assertEqual(result["code"], 0)
|
||||
self.assertEqual(result["data"]["total_pages"], 1)
|
||||
self.assertEqual(result["data"]["learnware_list"][0]["learnware_id"], learnware_id)
|
||||
|
||||
# result = testops.url_request("user/delete_learnware", {"learnware_id": learnware_id}, headers=headers)
|
||||
result = testops.url_request("user/delete_learnware", {"learnware_id": learnware_id}, headers=headers)
|
||||
|
||||
# self.assertEqual(result["code"], 0)
|
||||
self.assertEqual(result["code"], 0)
|
||||
|
||||
# result = testops.url_request("user/list_learnware", {"page": 0, "limit": 10, "is_verified": False}, headers=headers)
|
||||
result = testops.url_request(
|
||||
"user/list_learnware", {"page": 0, "limit": 10, "is_verified": False}, headers=headers
|
||||
)
|
||||
|
||||
# self.assertEqual(result["code"], 0)
|
||||
# self.assertEqual(len(result["data"]["learnware_list"]), 0)
|
||||
self.assertEqual(result["code"], 0)
|
||||
self.assertEqual(len(result["data"]["learnware_list"]), 0)
|
||||
|
||||
# pass
|
||||
pass
|
||||
|
||||
# def test_add_learnware(self):
|
||||
# headers = testops.login(TestUser.email, TestUser.password)
|
||||
# semantic_specification = testops.test_learnware_semantic_specification()
|
||||
def test_add_learnware(self):
|
||||
headers = testops.login(TestUser.email, TestUser.password)
|
||||
semantic_specification = testops.test_learnware_semantic_specification()
|
||||
|
||||
# learnware_file = open(os.path.join("tests", "data", "test_learnware.zip"), "rb")
|
||||
# files = {"learnware_file": learnware_file}
|
||||
learnware_file = open(os.path.join("tests", "data", "test_learnware.zip"), "rb")
|
||||
files = {"learnware_file": learnware_file}
|
||||
|
||||
# # print(semantic_specification)
|
||||
# result = testops.url_request(
|
||||
# "user/add_learnware",
|
||||
# {"semantic_specification": json.dumps(semantic_specification)},
|
||||
# files=files,
|
||||
# headers=headers,
|
||||
# )
|
||||
# print(semantic_specification)
|
||||
result = testops.url_request(
|
||||
"user/add_learnware",
|
||||
{"semantic_specification": json.dumps(semantic_specification)},
|
||||
files=files,
|
||||
headers=headers,
|
||||
)
|
||||
|
||||
# learnware_file.close()
|
||||
# self.assertEqual(result["code"], 0)
|
||||
# learnware_id = result["data"]["learnware_id"]
|
||||
# learnware_info, _ = dbops.get_learnware_list(by="learnware_id", value=learnware_id)
|
||||
# learnware_info = learnware_info[0]
|
||||
# self.assertEqual(learnware_info["verify_status"], "WAITING")
|
||||
learnware_file.close()
|
||||
self.assertEqual(result["code"], 0)
|
||||
learnware_id = result["data"]["learnware_id"]
|
||||
learnware_info, _ = dbops.get_learnware_list(by="learnware_id", value=learnware_id)
|
||||
learnware_info = learnware_info[0]
|
||||
self.assertEqual(learnware_info["verify_status"], "WAITING")
|
||||
|
||||
# testops.delete_learnware(learnware_id, headers)
|
||||
# pass
|
||||
testops.delete_learnware(learnware_id, headers)
|
||||
pass
|
||||
|
||||
def test_add_folder_learnware(self):
|
||||
headers = testops.login(TestUser.email, TestUser.password)
|
||||
|
@ -166,229 +168,231 @@ class TestUser(unittest.TestCase):
|
|||
testops.delete_learnware(learnware_id, headers)
|
||||
pass
|
||||
|
||||
# def test_update_unverified_learnware(self):
|
||||
# headers = testops.login(TestUser.email, TestUser.password)
|
||||
# semantic_specification = testops.test_learnware_semantic_specification()
|
||||
def test_update_unverified_learnware(self):
|
||||
headers = testops.login(TestUser.email, TestUser.password)
|
||||
semantic_specification = testops.test_learnware_semantic_specification()
|
||||
|
||||
# learnware_file = open(os.path.join("tests", "data", "test_learnware.zip"), "rb")
|
||||
# files = {"learnware_file": learnware_file}
|
||||
learnware_file = open(os.path.join("tests", "data", "test_learnware.zip"), "rb")
|
||||
files = {"learnware_file": learnware_file}
|
||||
|
||||
# # print(semantic_specification)
|
||||
# result = testops.url_request(
|
||||
# "user/add_learnware",
|
||||
# {"semantic_specification": json.dumps(semantic_specification)},
|
||||
# files=files,
|
||||
# headers=headers,
|
||||
# )
|
||||
# print(semantic_specification)
|
||||
result = testops.url_request(
|
||||
"user/add_learnware",
|
||||
{"semantic_specification": json.dumps(semantic_specification)},
|
||||
files=files,
|
||||
headers=headers,
|
||||
)
|
||||
|
||||
# learnware_file.close()
|
||||
# self.assertEqual(result["code"], 0)
|
||||
# learnware_id = result["data"]["learnware_id"]
|
||||
learnware_file.close()
|
||||
self.assertEqual(result["code"], 0)
|
||||
learnware_id = result["data"]["learnware_id"]
|
||||
|
||||
# result = testops.url_request("user/list_learnware", {"page": 0, "limit": 10}, headers=headers)
|
||||
result = testops.url_request("user/list_learnware", {"page": 0, "limit": 10}, headers=headers)
|
||||
|
||||
# self.assertEqual(result["code"], 0)
|
||||
# learnware_info = result["data"]["learnware_list"][0]
|
||||
# print(learnware_info.keys())
|
||||
# self.assertEqual(learnware_info["semantic_specification"]["Name"]["Values"], "Test Classification")
|
||||
self.assertEqual(result["code"], 0)
|
||||
learnware_info = result["data"]["learnware_list"][0]
|
||||
print(learnware_info.keys())
|
||||
self.assertEqual(learnware_info["semantic_specification"]["Name"]["Values"], "Test Classification")
|
||||
|
||||
# semantic_specification["Name"]["Values"] = "Test Classification 2"
|
||||
# dbops.update_learnware_timestamp(learnware_id, timestamp=(datetime.datetime.now() - datetime.timedelta(days=1)))
|
||||
# result = testops.url_request(
|
||||
# "user/update_learnware",
|
||||
# data={"learnware_id": learnware_id, "semantic_specification": json.dumps(semantic_specification)},
|
||||
# headers=headers,
|
||||
# )
|
||||
semantic_specification["Name"]["Values"] = "Test Classification 2"
|
||||
dbops.update_learnware_timestamp(learnware_id, timestamp=(datetime.datetime.now() - datetime.timedelta(days=1)))
|
||||
result = testops.url_request(
|
||||
"user/update_learnware",
|
||||
data={"learnware_id": learnware_id, "semantic_specification": json.dumps(semantic_specification)},
|
||||
headers=headers,
|
||||
)
|
||||
|
||||
# self.assertEqual(result["code"], 0)
|
||||
self.assertEqual(result["code"], 0)
|
||||
|
||||
# result = testops.url_request("user/list_learnware", {"page": 0, "limit": 10}, headers=headers)
|
||||
result = testops.url_request("user/list_learnware", {"page": 0, "limit": 10}, headers=headers)
|
||||
|
||||
# self.assertEqual(result["code"], 0)
|
||||
# learnware_info = result["data"]["learnware_list"][0]
|
||||
# self.assertEqual(learnware_info["semantic_specification"]["Name"]["Values"], "Test Classification 2")
|
||||
# print("---------------" + learnware_info["last_modify"])
|
||||
# last_modify = datetime.datetime.strptime(learnware_info["last_modify"], "%Y-%m-%d %H:%M:%S.%f %Z")
|
||||
# self.assertTrue((datetime.datetime.now() - last_modify).total_seconds() < 10)
|
||||
self.assertEqual(result["code"], 0)
|
||||
learnware_info = result["data"]["learnware_list"][0]
|
||||
self.assertEqual(learnware_info["semantic_specification"]["Name"]["Values"], "Test Classification 2")
|
||||
print("---------------" + learnware_info["last_modify"])
|
||||
last_modify = datetime.datetime.strptime(learnware_info["last_modify"], "%Y-%m-%d %H:%M:%S.%f %Z")
|
||||
self.assertTrue((datetime.datetime.now() - last_modify).total_seconds() < 10)
|
||||
|
||||
# testops.delete_learnware(learnware_id, headers)
|
||||
# pass
|
||||
testops.delete_learnware(learnware_id, headers)
|
||||
pass
|
||||
|
||||
# def test_update_verified_learnware(self):
|
||||
# headers = testops.login(TestUser.email, TestUser.password)
|
||||
def test_update_verified_learnware(self):
|
||||
headers = testops.login(TestUser.email, TestUser.password)
|
||||
|
||||
# learnware_id = testops.add_test_learnware(TestUser.email, TestUser.password)
|
||||
learnware_id = testops.add_test_learnware(TestUser.email, TestUser.password)
|
||||
|
||||
# result = testops.url_request("user/list_learnware", {"page": 0, "limit": 10}, headers=headers)
|
||||
result = testops.url_request("user/list_learnware", {"page": 0, "limit": 10}, headers=headers)
|
||||
|
||||
# self.assertEqual(result["code"], 0)
|
||||
# learnware_info = result["data"]["learnware_list"][0]
|
||||
# self.assertEqual(learnware_info["semantic_specification"]["Name"]["Values"], "Test Classification")
|
||||
self.assertEqual(result["code"], 0)
|
||||
learnware_info = result["data"]["learnware_list"][0]
|
||||
self.assertEqual(learnware_info["semantic_specification"]["Name"]["Values"], "Test Classification")
|
||||
|
||||
# semantic_specification = learnware_info["semantic_specification"]
|
||||
semantic_specification = learnware_info["semantic_specification"]
|
||||
|
||||
# semantic_specification["Name"]["Values"] = "Test Classification 2"
|
||||
# result = testops.url_request(
|
||||
# "user/update_learnware",
|
||||
# data={"learnware_id": learnware_id, "semantic_specification": json.dumps(semantic_specification)},
|
||||
# headers=headers,
|
||||
# )
|
||||
semantic_specification["Name"]["Values"] = "Test Classification 2"
|
||||
result = testops.url_request(
|
||||
"user/update_learnware",
|
||||
data={"learnware_id": learnware_id, "semantic_specification": json.dumps(semantic_specification)},
|
||||
headers=headers,
|
||||
)
|
||||
|
||||
# self.assertEqual(result["code"], 0)
|
||||
# result = testops.url_request("user/list_learnware", {"page": 0, "limit": 10, "is_verified": True}, headers=headers)
|
||||
self.assertEqual(result["code"], 0)
|
||||
result = testops.url_request(
|
||||
"user/list_learnware", {"page": 0, "limit": 10, "is_verified": False}, headers=headers
|
||||
)
|
||||
|
||||
# self.assertEqual(result["code"], 0)
|
||||
# learnware_info = result["data"]["learnware_list"][0]
|
||||
# self.assertEqual(learnware_info["semantic_specification"]["Name"]["Values"], "Test Classification 2")
|
||||
# self.assertEqual(learnware_info["verify_status"], "SUCCESS")
|
||||
self.assertEqual(result["code"], 0)
|
||||
learnware_info = result["data"]["learnware_list"][0]
|
||||
self.assertEqual(learnware_info["semantic_specification"]["Name"]["Values"], "Test Classification 2")
|
||||
assert learnware_info["verify_status"] != "SUCCESS"
|
||||
|
||||
# testops.delete_learnware(learnware_id, headers)
|
||||
# pass
|
||||
testops.delete_learnware(learnware_id, headers)
|
||||
pass
|
||||
|
||||
# def test_update_verified_learnware_and_file(self):
|
||||
# headers = testops.login(TestUser.email, TestUser.password)
|
||||
# semantic_specification = testops.test_learnware_semantic_specification()
|
||||
def test_update_verified_learnware_and_file(self):
|
||||
headers = testops.login(TestUser.email, TestUser.password)
|
||||
semantic_specification = testops.test_learnware_semantic_specification()
|
||||
|
||||
# learnware_file = open(os.path.join("tests", "data", "test_learnware.zip"), "rb")
|
||||
# files = {"learnware_file": learnware_file}
|
||||
learnware_file = open(os.path.join("tests", "data", "test_learnware.zip"), "rb")
|
||||
files = {"learnware_file": learnware_file}
|
||||
|
||||
# # print(semantic_specification)
|
||||
# result = testops.url_request(
|
||||
# "user/add_learnware",
|
||||
# {"semantic_specification": json.dumps(semantic_specification)},
|
||||
# files=files,
|
||||
# headers=headers,
|
||||
# )
|
||||
# print(semantic_specification)
|
||||
result = testops.url_request(
|
||||
"user/add_learnware",
|
||||
{"semantic_specification": json.dumps(semantic_specification)},
|
||||
files=files,
|
||||
headers=headers,
|
||||
)
|
||||
|
||||
# learnware_file.close()
|
||||
# self.assertEqual(result["code"], 0)
|
||||
# learnware_id = result["data"]["learnware_id"]
|
||||
learnware_file.close()
|
||||
self.assertEqual(result["code"], 0)
|
||||
learnware_id = result["data"]["learnware_id"]
|
||||
|
||||
# testops.add_learnware_to_engine(learnware_id, headers)
|
||||
testops.add_learnware_to_engine(learnware_id, headers)
|
||||
|
||||
# response = testops.url_request(
|
||||
# "engine/download_learnware",
|
||||
# {"learnware_id": learnware_id},
|
||||
# headers=headers,
|
||||
# method="get",
|
||||
# return_response=True,
|
||||
# )
|
||||
response = testops.url_request(
|
||||
"engine/download_learnware",
|
||||
{"learnware_id": learnware_id},
|
||||
headers=headers,
|
||||
method="get",
|
||||
return_response=True,
|
||||
)
|
||||
|
||||
# self.assertEqual(len(response.content), os.path.getsize(os.path.join("tests", "data", "test_learnware.zip")))
|
||||
self.assertEqual(len(response.content), os.path.getsize(os.path.join("tests", "data", "test_learnware.zip")))
|
||||
|
||||
# learnware_file = open(os.path.join("tests", "data", "test_learnware2.zip"), "rb")
|
||||
# files = {"learnware_file": learnware_file}
|
||||
learnware_file = open(os.path.join("tests", "data", "test_learnware2.zip"), "rb")
|
||||
files = {"learnware_file": learnware_file}
|
||||
|
||||
# result = testops.url_request(
|
||||
# "user/update_learnware",
|
||||
# data={"learnware_id": learnware_id, "semantic_specification": json.dumps(semantic_specification)},
|
||||
# files=files,
|
||||
# headers=headers,
|
||||
# )
|
||||
# learnware_file.close()
|
||||
result = testops.url_request(
|
||||
"user/update_learnware",
|
||||
data={"learnware_id": learnware_id, "semantic_specification": json.dumps(semantic_specification)},
|
||||
files=files,
|
||||
headers=headers,
|
||||
)
|
||||
learnware_file.close()
|
||||
|
||||
# result = testops.url_request("user/list_learnware", {"page": 0, "limit": 10}, headers=headers)
|
||||
result = testops.url_request("user/list_learnware", {"page": 0, "limit": 10}, headers=headers)
|
||||
|
||||
# self.assertEqual(result["code"], 0)
|
||||
# learnware_info = result["data"]["learnware_list"][0]
|
||||
# self.assertEqual(learnware_info["verify_status"], "WAITING")
|
||||
# self.assertTrue(os.path.exists(context.get_learnware_verify_file_path(learnware_id)))
|
||||
self.assertEqual(result["code"], 0)
|
||||
learnware_info = result["data"]["learnware_list"][0]
|
||||
self.assertEqual(learnware_info["verify_status"], "WAITING")
|
||||
self.assertTrue(os.path.exists(context.get_learnware_verify_file_path(learnware_id)))
|
||||
|
||||
# response = testops.url_request(
|
||||
# "engine/download_learnware",
|
||||
# {"learnware_id": learnware_id},
|
||||
# headers=headers,
|
||||
# method="get",
|
||||
# return_response=True,
|
||||
# )
|
||||
response = testops.url_request(
|
||||
"engine/download_learnware",
|
||||
{"learnware_id": learnware_id},
|
||||
headers=headers,
|
||||
method="get",
|
||||
return_response=True,
|
||||
)
|
||||
|
||||
# self.assertEqual(len(response.content), os.path.getsize(os.path.join("tests", "data", "test_learnware2.zip")))
|
||||
self.assertEqual(len(response.content), os.path.getsize(os.path.join("tests", "data", "test_learnware2.zip")))
|
||||
|
||||
# testops.delete_learnware(learnware_id, headers)
|
||||
# pass
|
||||
testops.delete_learnware(learnware_id, headers)
|
||||
pass
|
||||
|
||||
# def test_verify_log(self):
|
||||
# learnware_id = testops.add_test_learnware(TestUser.email, TestUser.password)
|
||||
# dbops.update_learnware_verify_result(learnware_id, LearnwareVerifyStatus.SUCCESS, "test result")
|
||||
# headers = testops.login(TestUser.email, TestUser.password)
|
||||
def test_verify_log(self):
|
||||
learnware_id = testops.add_test_learnware(TestUser.email, TestUser.password)
|
||||
dbops.update_learnware_verify_result(learnware_id, LearnwareVerifyStatus.SUCCESS, "test result")
|
||||
headers = testops.login(TestUser.email, TestUser.password)
|
||||
|
||||
# result = testops.url_request(
|
||||
# "user/verify_log?learnware_id={}".format(learnware_id),
|
||||
# {},
|
||||
# headers=headers,
|
||||
# method="get",
|
||||
# return_response=True,
|
||||
# )
|
||||
result = testops.url_request(
|
||||
"user/verify_log?learnware_id={}".format(learnware_id),
|
||||
{},
|
||||
headers=headers,
|
||||
method="get",
|
||||
return_response=True,
|
||||
)
|
||||
|
||||
# result = result.json()["data"]
|
||||
result = result.json()["data"]
|
||||
|
||||
# self.assertEqual(result, "test result")
|
||||
# testops.delete_learnware(learnware_id, headers)
|
||||
# pass
|
||||
self.assertEqual(result, "test result")
|
||||
testops.delete_learnware(learnware_id, headers)
|
||||
pass
|
||||
|
||||
# def test_verify_log_by_admin(self):
|
||||
# learnware_id = testops.add_test_learnware(TestUser.email, TestUser.password)
|
||||
# dbops.update_learnware_verify_result(learnware_id, LearnwareVerifyStatus.SUCCESS, "test result")
|
||||
# headers = testops.login("test@localhost", "test")
|
||||
def test_verify_log_by_admin(self):
|
||||
learnware_id = testops.add_test_learnware(TestUser.email, TestUser.password)
|
||||
dbops.update_learnware_verify_result(learnware_id, LearnwareVerifyStatus.SUCCESS, "test result")
|
||||
headers = testops.login("test@localhost", "test")
|
||||
|
||||
# result = testops.url_request(
|
||||
# "user/verify_log?learnware_id={}".format(learnware_id),
|
||||
# {},
|
||||
# headers=headers,
|
||||
# method="get",
|
||||
# return_response=True,
|
||||
# )
|
||||
result = testops.url_request(
|
||||
"user/verify_log?learnware_id={}".format(learnware_id),
|
||||
{},
|
||||
headers=headers,
|
||||
method="get",
|
||||
return_response=True,
|
||||
)
|
||||
|
||||
# result = result.json()["data"]
|
||||
result = result.json()["data"]
|
||||
|
||||
# self.assertEqual(result, "test result")
|
||||
# testops.delete_learnware(learnware_id, headers)
|
||||
# pass
|
||||
self.assertEqual(result, "test result")
|
||||
testops.delete_learnware(learnware_id, headers)
|
||||
pass
|
||||
|
||||
# def test_add_learnware_no_stat_file(self):
|
||||
# headers = testops.login(TestUser.email, TestUser.password)
|
||||
# semantic_specification = testops.test_learnware_semantic_specification()
|
||||
def test_add_learnware_no_stat_file(self):
|
||||
headers = testops.login(TestUser.email, TestUser.password)
|
||||
semantic_specification = testops.test_learnware_semantic_specification()
|
||||
|
||||
# learnware_file = open(os.path.join("tests", "data", "test_learnware_no_stat.zip"), "rb")
|
||||
# files = {"learnware_file": learnware_file}
|
||||
learnware_file = open(os.path.join("tests", "data", "test_learnware_no_stat.zip"), "rb")
|
||||
files = {"learnware_file": learnware_file}
|
||||
|
||||
# # print(semantic_specification)
|
||||
# result = testops.url_request(
|
||||
# "user/add_learnware",
|
||||
# {"semantic_specification": json.dumps(semantic_specification)},
|
||||
# files=files,
|
||||
# headers=headers,
|
||||
# )
|
||||
# print(semantic_specification)
|
||||
result = testops.url_request(
|
||||
"user/add_learnware",
|
||||
{"semantic_specification": json.dumps(semantic_specification)},
|
||||
files=files,
|
||||
headers=headers,
|
||||
)
|
||||
|
||||
# learnware_file.close()
|
||||
# self.assertEqual(result["code"], 51)
|
||||
learnware_file.close()
|
||||
self.assertEqual(result["code"], 51)
|
||||
|
||||
# pass
|
||||
pass
|
||||
|
||||
# def test_create_token(self):
|
||||
# headers = testops.login(TestUser.email, TestUser.password)
|
||||
def test_create_token(self):
|
||||
headers = testops.login(TestUser.email, TestUser.password)
|
||||
|
||||
# result = testops.url_request("user/create_token", {}, headers=headers)
|
||||
result = testops.url_request("user/create_token", {}, headers=headers)
|
||||
|
||||
# self.assertEqual(result["code"], 0)
|
||||
self.assertEqual(result["code"], 0)
|
||||
|
||||
# token = result["data"]["token"]
|
||||
token = result["data"]["token"]
|
||||
|
||||
# result = testops.url_request("user/list_token", {}, headers=headers)
|
||||
result = testops.url_request("user/list_token", {}, headers=headers)
|
||||
|
||||
# self.assertEqual(result["code"], 0)
|
||||
# self.assertIn(token, result["data"]["token_list"])
|
||||
self.assertEqual(result["code"], 0)
|
||||
self.assertIn(token, result["data"]["token_list"])
|
||||
|
||||
# result = testops.url_request("user/delete_token", {"token": token}, headers=headers)
|
||||
result = testops.url_request("user/delete_token", {"token": token}, headers=headers)
|
||||
|
||||
# self.assertEqual(result["code"], 0)
|
||||
self.assertEqual(result["code"], 0)
|
||||
|
||||
# result = testops.url_request("user/list_token", {}, headers=headers)
|
||||
result = testops.url_request("user/list_token", {}, headers=headers)
|
||||
|
||||
# print(result)
|
||||
# self.assertEqual(result["code"], 0)
|
||||
# self.assertEqual(len(result["data"]["token_list"]), 0)
|
||||
# pass
|
||||
print(result)
|
||||
self.assertEqual(result["code"], 0)
|
||||
self.assertEqual(len(result["data"]["token_list"]), 0)
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in New Issue