From 7d2bb86cce10ee6a8e81aaad810544a4ca38cec9 Mon Sep 17 00:00:00 2001 From: Vladimir Repin <32306715+mezotaken@users.noreply.github.com> Date: Mon, 9 Jan 2023 19:39:06 +0300 Subject: combine tests together, return set options test --- test/basic_features/extras_test.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/basic_features/extras_test.py (limited to 'test/basic_features/extras_test.py') diff --git a/test/basic_features/extras_test.py b/test/basic_features/extras_test.py new file mode 100644 index 00000000..8763f8ed --- /dev/null +++ b/test/basic_features/extras_test.py @@ -0,0 +1,29 @@ +import unittest + + +class TestExtrasWorking(unittest.TestCase): + def setUp(self): + self.url_img2img = "http://localhost:7860/sdapi/v1/extra-single-image" + self.simple_extras = { + "resize_mode": 0, + "show_extras_results": True, + "gfpgan_visibility": 0, + "codeformer_visibility": 0, + "codeformer_weight": 0, + "upscaling_resize": 2, + "upscaling_resize_w": 128, + "upscaling_resize_h": 128, + "upscaling_crop": True, + "upscaler_1": "None", + "upscaler_2": "None", + "extras_upscaler_2_visibility": 0, + "image": "" + } + + +class TestExtrasCorrectness(unittest.TestCase): + pass + + +if __name__ == "__main__": + unittest.main() -- cgit v1.2.3 From 00005ac9af10d58a75f7ce0aa04db78775808e93 Mon Sep 17 00:00:00 2001 From: Vladimir Repin <32306715+mezotaken@users.noreply.github.com> Date: Mon, 9 Jan 2023 21:01:28 +0300 Subject: add more tests --- test/basic_features/extras_test.py | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'test/basic_features/extras_test.py') diff --git a/test/basic_features/extras_test.py b/test/basic_features/extras_test.py index 8763f8ed..0170c511 100644 --- a/test/basic_features/extras_test.py +++ b/test/basic_features/extras_test.py @@ -1,10 +1,12 @@ import unittest - +import requests +from gradio.processing_utils import encode_pil_to_base64 +from PIL import Image class TestExtrasWorking(unittest.TestCase): def setUp(self): - self.url_img2img = "http://localhost:7860/sdapi/v1/extra-single-image" - self.simple_extras = { + self.url_extras_single = "http://localhost:7860/sdapi/v1/extra-single-image" + self.extras_single = { "resize_mode": 0, "show_extras_results": True, "gfpgan_visibility": 0, @@ -17,12 +19,35 @@ class TestExtrasWorking(unittest.TestCase): "upscaler_1": "None", "upscaler_2": "None", "extras_upscaler_2_visibility": 0, - "image": "" + "image": encode_pil_to_base64(Image.open(r"test/test_files/img2img_basic.png")) } + def test_simple_upscaling_performed(self): + self.extras_single["upscaler_1"] = "Lanczos" + self.assertEqual(requests.post(self.url_extras_single, json=self.extras_single).status_code, 200) + + +class TestPngInfoWorking(unittest.TestCase): + def setUp(self): + self.url_png_info = "http://localhost:7860/sdapi/v1/extra-single-image" + self.png_info = { + "image": encode_pil_to_base64(Image.open(r"test/test_files/img2img_basic.png")) + } + + def test_png_info_performed(self): + self.assertEqual(requests.post(self.url_png_info, json=self.png_info).status_code, 200) + + +class TestInterrogateWorking(unittest.TestCase): + def setUp(self): + self.url_interrogate = "http://localhost:7860/sdapi/v1/extra-single-image" + self.interrogate = { + "image": encode_pil_to_base64(Image.open(r"test/test_files/img2img_basic.png")), + "model": "clip" + } -class TestExtrasCorrectness(unittest.TestCase): - pass + def test_interrogate_performed(self): + self.assertEqual(requests.post(self.url_interrogate, json=self.interrogate).status_code, 200) if __name__ == "__main__": -- cgit v1.2.3