Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
stable-diffusion-webui
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
stable-diffusion-webui
Commits
007f4f73
Commit
007f4f73
authored
Nov 12, 2022
by
Vladimir Repin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests cleaned up
parent
98947d17
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
14 deletions
+20
-14
launch.py
launch.py
+4
-1
server_poll.py
test/server_poll.py
+4
-3
empty.pt
test/test_files/empty.pt
+0
-0
txt2img_test.py
test/txt2img_test.py
+3
-1
utils_test.py
test/utils_test.py
+9
-9
No files found.
launch.py
View file @
007f4f73
...
@@ -229,6 +229,9 @@ def prepare_enviroment():
...
@@ -229,6 +229,9 @@ def prepare_enviroment():
def
tests
(
argv
):
def
tests
(
argv
):
if
"--api"
not
in
argv
:
if
"--api"
not
in
argv
:
argv
.
append
(
"--api"
)
argv
.
append
(
"--api"
)
if
"--ckpt"
not
in
argv
:
argv
.
append
(
"--ckpt"
)
argv
.
append
(
"./test/test_files/empty.pt"
)
print
(
f
"Launching Web UI in another process for testing with arguments: {' '.join(argv[1:])}"
)
print
(
f
"Launching Web UI in another process for testing with arguments: {' '.join(argv[1:])}"
)
...
@@ -236,7 +239,7 @@ def tests(argv):
...
@@ -236,7 +239,7 @@ def tests(argv):
proc
=
subprocess
.
Popen
([
sys
.
executable
,
*
argv
],
stdout
=
stdout
,
stderr
=
stderr
)
proc
=
subprocess
.
Popen
([
sys
.
executable
,
*
argv
],
stdout
=
stdout
,
stderr
=
stderr
)
import
test.server_poll
import
test.server_poll
test
.
server_poll
.
run_tests
()
test
.
server_poll
.
run_tests
(
proc
)
print
(
f
"Stopping Web UI process with id {proc.pid}"
)
print
(
f
"Stopping Web UI process with id {proc.pid}"
)
proc
.
kill
()
proc
.
kill
()
...
...
test/server_poll.py
View file @
007f4f73
...
@@ -3,7 +3,7 @@ import requests
...
@@ -3,7 +3,7 @@ import requests
import
time
import
time
def
run_tests
():
def
run_tests
(
proc
):
timeout_threshold
=
240
timeout_threshold
=
240
start_time
=
time
.
time
()
start_time
=
time
.
time
()
while
time
.
time
()
-
start_time
<
timeout_threshold
:
while
time
.
time
()
-
start_time
<
timeout_threshold
:
...
@@ -11,8 +11,9 @@ def run_tests():
...
@@ -11,8 +11,9 @@ def run_tests():
requests
.
head
(
"http://localhost:7860/"
)
requests
.
head
(
"http://localhost:7860/"
)
break
break
except
requests
.
exceptions
.
ConnectionError
:
except
requests
.
exceptions
.
ConnectionError
:
pass
if
proc
.
poll
()
is
not
None
:
if
time
.
time
()
-
start_time
<
timeout_threshold
:
break
if
proc
.
poll
()
is
None
:
suite
=
unittest
.
TestLoader
()
.
discover
(
''
,
pattern
=
'*_test.py'
)
suite
=
unittest
.
TestLoader
()
.
discover
(
''
,
pattern
=
'*_test.py'
)
result
=
unittest
.
TextTestRunner
(
verbosity
=
2
)
.
run
(
suite
)
result
=
unittest
.
TextTestRunner
(
verbosity
=
2
)
.
run
(
suite
)
else
:
else
:
...
...
test/test_files/empty.pt
0 → 100644
View file @
007f4f73
File added
test/txt2img_test.py
View file @
007f4f73
...
@@ -53,13 +53,15 @@ class TestTxt2ImgWorking(unittest.TestCase):
...
@@ -53,13 +53,15 @@ class TestTxt2ImgWorking(unittest.TestCase):
self
.
simple_txt2img
[
"restore_faces"
]
=
True
self
.
simple_txt2img
[
"restore_faces"
]
=
True
self
.
assertEqual
(
requests
.
post
(
self
.
url_txt2img
,
json
=
self
.
simple_txt2img
)
.
status_code
,
200
)
self
.
assertEqual
(
requests
.
post
(
self
.
url_txt2img
,
json
=
self
.
simple_txt2img
)
.
status_code
,
200
)
def
test_txt2img_with_tiling_
faces_
performed
(
self
):
def
test_txt2img_with_tiling_performed
(
self
):
self
.
simple_txt2img
[
"tiling"
]
=
True
self
.
simple_txt2img
[
"tiling"
]
=
True
self
.
assertEqual
(
requests
.
post
(
self
.
url_txt2img
,
json
=
self
.
simple_txt2img
)
.
status_code
,
200
)
self
.
assertEqual
(
requests
.
post
(
self
.
url_txt2img
,
json
=
self
.
simple_txt2img
)
.
status_code
,
200
)
def
test_txt2img_with_vanilla_sampler_performed
(
self
):
def
test_txt2img_with_vanilla_sampler_performed
(
self
):
self
.
simple_txt2img
[
"sampler_index"
]
=
"PLMS"
self
.
simple_txt2img
[
"sampler_index"
]
=
"PLMS"
self
.
assertEqual
(
requests
.
post
(
self
.
url_txt2img
,
json
=
self
.
simple_txt2img
)
.
status_code
,
200
)
self
.
assertEqual
(
requests
.
post
(
self
.
url_txt2img
,
json
=
self
.
simple_txt2img
)
.
status_code
,
200
)
self
.
simple_txt2img
[
"sampler_index"
]
=
"DDIM"
self
.
assertEqual
(
requests
.
post
(
self
.
url_txt2img
,
json
=
self
.
simple_txt2img
)
.
status_code
,
200
)
def
test_txt2img_multiple_batches_performed
(
self
):
def
test_txt2img_multiple_batches_performed
(
self
):
self
.
simple_txt2img
[
"n_iter"
]
=
2
self
.
simple_txt2img
[
"n_iter"
]
=
2
...
...
test/utils_test.py
View file @
007f4f73
...
@@ -18,19 +18,19 @@ class UtilsTests(unittest.TestCase):
...
@@ -18,19 +18,19 @@ class UtilsTests(unittest.TestCase):
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
)
def
test_options_write
(
self
):
#
def test_options_write(self):
response
=
requests
.
get
(
self
.
url_options
)
#
response = requests.get(self.url_options)
self
.
assertEqual
(
response
.
status_code
,
200
)
#
self.assertEqual(response.status_code, 200)
pre_value
=
response
.
json
()[
"send_seed"
]
#
pre_value = response.json()["send_seed"]
self
.
assertEqual
(
requests
.
post
(
self
.
url_options
,
json
=
{
"send_seed"
:
not
pre_value
})
.
status_code
,
200
)
#
self.assertEqual(requests.post(self.url_options, json={"send_seed":not pre_value}).status_code, 200)
response
=
requests
.
get
(
self
.
url_options
)
#
response = requests.get(self.url_options)
self
.
assertEqual
(
response
.
status_code
,
200
)
#
self.assertEqual(response.status_code, 200)
self
.
assertEqual
(
response
.
json
()[
"send_seed"
],
not
pre_value
)
#
self.assertEqual(response.json()["send_seed"], not pre_value)
requests
.
post
(
self
.
url_options
,
json
=
{
"send_seed"
:
pre_value
})
#
requests.post(self.url_options, json={"send_seed": pre_value})
def
test_cmd_flags
(
self
):
def
test_cmd_flags
(
self
):
self
.
assertEqual
(
requests
.
get
(
self
.
url_cmd_flags
)
.
status_code
,
200
)
self
.
assertEqual
(
requests
.
get
(
self
.
url_cmd_flags
)
.
status_code
,
200
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment