Download microsoftexcel-controlnet/tests/web_api/detect_test.py from toto10/extensions: direct link, hf CLI and curl.
- Browser
- Download file 1.32 kB
-
https://huggingface.co/toto10/extensions/resolve/refs%2Fpr%2F4/microsoftexcel-controlnet/tests/web_api/detect_test.py
- Command line
-
hf download hf://toto10/extensions@refs/pr/4/microsoftexcel-controlnet/tests/web_api/detect_test.py
-
curl -L -o detect_test.py https://huggingface.co/toto10/extensions/resolve/refs%2Fpr%2F4/microsoftexcel-controlnet/tests/web_api/detect_test.py
1.32 kB
| import requests | |
| import unittest | |
| import importlib | |
| utils = importlib.import_module( | |
| 'extensions.sd-webui-controlnet.tests.utils', 'utils') | |
| utils.setup_test_env() | |
| class TestDetectEndpointWorking(unittest.TestCase): | |
| def setUp(self): | |
| self.base_detect_args = { | |
| "controlnet_module": "canny", | |
| "controlnet_input_images": [utils.readImage("test/test_files/img2img_basic.png")], | |
| "controlnet_processor_res": 512, | |
| "controlnet_threshold_a": 0, | |
| "controlnet_threshold_b": 0, | |
| } | |
| def test_detect_with_invalid_module_performed(self): | |
| detect_args = self.base_detect_args.copy() | |
| detect_args.update({ | |
| "controlnet_module": "INVALID", | |
| }) | |
| self.assertEqual(utils.detect(detect_args).status_code, 422) | |
| def test_detect_with_no_input_images_performed(self): | |
| detect_args = self.base_detect_args.copy() | |
| detect_args.update({ | |
| "controlnet_input_images": [], | |
| }) | |
| self.assertEqual(utils.detect(detect_args).status_code, 422) | |
| def test_detect_with_valid_args_performed(self): | |
| detect_args = self.base_detect_args | |
| response = utils.detect(detect_args) | |
| self.assertEqual(response.status_code, 200) | |
| if __name__ == "__main__": | |
| unittest.main() | |