import os import unittest import tempfile from learnware.client import LearnwareClient class TestCheckLearnware(unittest.TestCase): def setUp(self): unittest.TestCase.setUpClass() self.client = LearnwareClient() def test_check_learnware_pip(self): learnware_id = "00000154" with tempfile.TemporaryDirectory(prefix="learnware_") as tempdir: self.zip_path = os.path.join(tempdir, "test.zip") self.client.download_learnware(learnware_id, self.zip_path) LearnwareClient.check_learnware(self.zip_path) def test_check_learnware_conda(self): learnware_id = "00000148" with tempfile.TemporaryDirectory(prefix="learnware_") as tempdir: self.zip_path = os.path.join(tempdir, "test.zip") self.client.download_learnware(learnware_id, self.zip_path) LearnwareClient.check_learnware(self.zip_path) def test_check_learnware_dependency(self): learnware_id = "00000147" with tempfile.TemporaryDirectory(prefix="learnware_") as tempdir: self.zip_path = os.path.join(tempdir, "test.zip") self.client.download_learnware(learnware_id, self.zip_path) LearnwareClient.check_learnware(self.zip_path) def test_check_learnware_image(self): learnware_id = "00000677" with tempfile.TemporaryDirectory(prefix="learnware_") as tempdir: self.zip_path = os.path.join(tempdir, "test.zip") self.client.download_learnware(learnware_id, self.zip_path) LearnwareClient.check_learnware(self.zip_path) def test_check_learnware_text(self): learnware_id = "00000662" with tempfile.TemporaryDirectory(prefix="learnware_") as tempdir: self.zip_path = os.path.join(tempdir, "test.zip") self.client.download_learnware(learnware_id, self.zip_path) LearnwareClient.check_learnware(self.zip_path) if __name__ == "__main__": unittest.main()