CS553_CaseStudy1 / test.py
smdbs
fix: remove pytorch dependency and make docker_build_and_push run after testspass
510d44e
Raw History Blame Contribute Delete
1.11 kB
import unittest
import os
from app import sd_2_1_base
HF_TOKEN = os.environ.get("HF_TOKEN", "YOUR_HF_TOKEN")
TOKEN_MSG = "Set HF_TOKEN to your Hugging Face token for using InferenceClient"
SKIP_MSG = "Skipping test because HF_TOKEN is not set"
class TestGeneralSetup(unittest.TestCase):
def test_setup(self):
self.assertTrue(HF_TOKEN != "YOUR_HF_TOKEN", TOKEN_MSG)
# class TestLocalModel(unittest.TestCase):
# @unittest.skipIf(HF_TOKEN == "YOUR_HF_TOKEN", SKIP_MSG)
# # @unittest.skipIf(not torch.cuda.is_available(), "CUDA is not available")
# def test_url_1(self):
# image, _ = sd_2_1_base(
# "A photo of a cat", True, "A photo of a dog", 42, False, 0.1, 10, 128, 128
# )
# self.assertIsNotNone(image)
class TestAPIModel(unittest.TestCase):
@unittest.skipIf(HF_TOKEN == "YOUR_HF_TOKEN", SKIP_MSG)
def test_url_1(self):
image, _ = sd_2_1_base(
"A photo of a cat", False, "A photo of a dog", 42, False, 0.1, 10, 128, 128
)
self.assertIsNotNone(image)
if __name__ == "__main__":
unittest.main()