Browse Source

[ENH] add test for check_learnware

tags/v0.3.2
Gene 2 years ago
parent
commit
ffaecc60f7
2 changed files with 27 additions and 23 deletions
  1. +27
    -0
      tests/test_learnware_client/test_check_learnware.py
  2. +0
    -23
      tests/test_learnware_client/test_learnware.py

+ 27
- 0
tests/test_learnware_client/test_check_learnware.py View File

@@ -0,0 +1,27 @@
import os
import unittest
import tempfile


from learnware.client import LearnwareClient


class TestCheckLearnware(unittest.TestCase):
def setUp(self):
unittest.TestCase.setUpClass()
email = "liujd@lamda.nju.edu.cn"
token = "f7e647146a314c6e8b4e2e1079c4bca4"

self.client = LearnwareClient()
self.client.login(email, token)
self.learnware_id = "00000154"

def test_check_learnware(self):
with tempfile.TemporaryDirectory(prefix="learnware_") as tempdir:
self.zip_path = os.path.join(tempdir, "test.zip")
self.client.download_learnware(self.learnware_id, self.zip_path)
LearnwareClient.check_learnware(self.zip_path)


if __name__ == "__main__":
unittest.main()

+ 0
- 23
tests/test_learnware_client/test_learnware.py View File

@@ -1,23 +0,0 @@
import os
import zipfile
import tempfile
from learnware.learnware import get_learnware_from_dirpath
from learnware.test import get_semantic_specification
from learnware.client.container import LearnwaresContainer
from learnware.market import EasyMarket

if __name__ == "__main__":
semantic_specification = get_semantic_specification()

zip_path = "rf_tic.zip"
with tempfile.TemporaryDirectory(suffix="learnware") as tempdir:
learnware_dirpath = os.path.join(tempdir, "test")
with zipfile.ZipFile(zip_path, "r") as z_file:
z_file.extractall(learnware_dirpath)
learnware = get_learnware_from_dirpath(
id="test", semantic_spec=semantic_specification, learnware_dirpath=learnware_dirpath
)

with LearnwaresContainer(learnware, zip_path) as env_container:
learnware = env_container.get_learnwares_with_container()[0]
print(EasyMarket.check_learnware(learnware))

Loading…
Cancel
Save