File size: 1,112 Bytes
3e1b1c6
 
 
66d8db1
1b23a4c
3e1b1c6
 
 
 
1b23a4c
3e1b1c6
 
 
 
a87e981
510d44e
 
 
 
 
 
 
 
1b23a4c
 
66d8db1
3e1b1c6
 
66d8db1
 
 
 
 
 
3e1b1c6
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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()