Use localhost with 80 port, count errors as well

This commit is contained in:
Vladimir Repin 2022-11-14 14:55:39 +03:00
parent 0646040667
commit 7416ac8d3c
6 changed files with 17 additions and 17 deletions

View file

@ -3,7 +3,7 @@ import unittest
class TestExtrasWorking(unittest.TestCase): class TestExtrasWorking(unittest.TestCase):
def setUp(self): def setUp(self):
self.url_img2img = "http://127.0.0.1:7860/sdapi/v1/extra-single-image" self.url_img2img = "http://localhost:80/sdapi/v1/extra-single-image"
self.simple_extras = { self.simple_extras = {
"resize_mode": 0, "resize_mode": 0,
"show_extras_results": True, "show_extras_results": True,

View file

@ -4,7 +4,7 @@ import requests
class TestTxt2ImgWorking(unittest.TestCase): class TestTxt2ImgWorking(unittest.TestCase):
def setUp(self): def setUp(self):
self.url_txt2img = "http://127.0.0.1:7860/sdapi/v1/txt2img" self.url_txt2img = "http://localhost:80/sdapi/v1/txt2img"
self.simple_txt2img = { self.simple_txt2img = {
"enable_hr": False, "enable_hr": False,
"denoising_strength": 0, "denoising_strength": 0,

View file

@ -6,7 +6,7 @@ from PIL import Image
class TestImg2ImgWorking(unittest.TestCase): class TestImg2ImgWorking(unittest.TestCase):
def setUp(self): def setUp(self):
self.url_img2img = "http://127.0.0.1:7860/sdapi/v1/img2img" self.url_img2img = "http://localhost:80/sdapi/v1/img2img"
self.simple_img2img = { self.simple_img2img = {
"init_images": [encode_pil_to_base64(Image.open(r"test/test_files/img2img_basic.png"))], "init_images": [encode_pil_to_base64(Image.open(r"test/test_files/img2img_basic.png"))],
"resize_mode": 0, "resize_mode": 0,

View file

@ -4,7 +4,7 @@ import requests
class TestTxt2ImgWorking(unittest.TestCase): class TestTxt2ImgWorking(unittest.TestCase):
def setUp(self): def setUp(self):
self.url_txt2img = "http://127.0.0.1:7860/sdapi/v1/txt2img" self.url_txt2img = "http://localhost:80/sdapi/v1/txt2img"
self.simple_txt2img = { self.simple_txt2img = {
"enable_hr": False, "enable_hr": False,
"denoising_strength": 0, "denoising_strength": 0,

View file

@ -3,17 +3,17 @@ import requests
class UtilsTests(unittest.TestCase): class UtilsTests(unittest.TestCase):
def setUp(self): def setUp(self):
self.url_options = "http://127.0.0.1:7860/sdapi/v1/options" self.url_options = "http://localhost:80/sdapi/v1/options"
self.url_cmd_flags = "http://127.0.0.1:7860/sdapi/v1/cmd-flags" self.url_cmd_flags = "http://localhost:80/sdapi/v1/cmd-flags"
self.url_samplers = "http://127.0.0.1:7860/sdapi/v1/samplers" self.url_samplers = "http://localhost:80/sdapi/v1/samplers"
self.url_upscalers = "http://127.0.0.1:7860/sdapi/v1/upscalers" self.url_upscalers = "http://localhost:80/sdapi/v1/upscalers"
self.url_sd_models = "http://127.0.0.1:7860/sdapi/v1/sd-models" self.url_sd_models = "http://localhost:80/sdapi/v1/sd-models"
self.url_hypernetworks = "http://127.0.0.1:7860/sdapi/v1/hypernetworks" self.url_hypernetworks = "http://localhost:80/sdapi/v1/hypernetworks"
self.url_face_restorers = "http://127.0.0.1:7860/sdapi/v1/face-restorers" self.url_face_restorers = "http://localhost:80/sdapi/v1/face-restorers"
self.url_realesrgan_models = "http://127.0.0.1:7860/sdapi/v1/realesrgan-models" self.url_realesrgan_models = "http://localhost:80/sdapi/v1/realesrgan-models"
self.url_prompt_styles = "http://127.0.0.1:7860/sdapi/v1/prompt-styles" self.url_prompt_styles = "http://localhost:80/sdapi/v1/prompt-styles"
self.url_artist_categories = "http://127.0.0.1:7860/sdapi/v1/artist-categories" self.url_artist_categories = "http://localhost:80/sdapi/v1/artist-categories"
self.url_artists = "http://127.0.0.1:7860/sdapi/v1/artists" self.url_artists = "http://localhost:80/sdapi/v1/artists"
def test_options_get(self): def test_options_get(self):
self.assertEqual(requests.get(self.url_options).status_code, 200) self.assertEqual(requests.get(self.url_options).status_code, 200)

View file

@ -8,7 +8,7 @@ def run_tests(proc, test_dir):
start_time = time.time() start_time = time.time()
while time.time()-start_time < timeout_threshold: while time.time()-start_time < timeout_threshold:
try: try:
requests.head("http://127.0.0.1:7860/") requests.head("http://localhost:80/")
break break
except requests.exceptions.ConnectionError: except requests.exceptions.ConnectionError:
if proc.poll() is not None: if proc.poll() is not None:
@ -18,7 +18,7 @@ def run_tests(proc, test_dir):
test_dir = "" test_dir = ""
suite = unittest.TestLoader().discover(test_dir, pattern="*_test.py", top_level_dir="test") suite = unittest.TestLoader().discover(test_dir, pattern="*_test.py", top_level_dir="test")
result = unittest.TextTestRunner(verbosity=2).run(suite) result = unittest.TextTestRunner(verbosity=2).run(suite)
return len(result.failures) return len(result.failures) + len(result.errors)
else: else:
print("Launch unsuccessful") print("Launch unsuccessful")
return 1 return 1