1
+ import unittest
2
+ import requests
3
+
4
+ class UtilsTests (unittest .TestCase ):
5
+ def setUp (self ):
6
+ self .url_options = "http://localhost:7860/sdapi/v1/options"
7
+ self .url_cmd_flags = "http://localhost:7860/sdapi/v1/cmd-flags"
8
+ self .url_samplers = "http://localhost:7860/sdapi/v1/samplers"
9
+ self .url_upscalers = "http://localhost:7860/sdapi/v1/upscalers"
10
+ self .url_sd_models = "http://localhost:7860/sdapi/v1/sd-models"
11
+ self .url_hypernetworks = "http://localhost:7860/sdapi/v1/hypernetworks"
12
+ self .url_face_restorers = "http://localhost:7860/sdapi/v1/face-restorers"
13
+ self .url_realesrgan_models = "http://localhost:7860/sdapi/v1/realesrgan-models"
14
+ self .url_prompt_styles = "http://localhost:7860/sdapi/v1/prompt-styles"
15
+ self .url_artist_categories = "http://localhost:7860/sdapi/v1/artist-categories"
16
+ self .url_artists = "http://localhost:7860/sdapi/v1/artists"
17
+
18
+ def test_options_get (self ):
19
+ self .assertEqual (requests .get (self .url_options ).status_code , 200 )
20
+
21
+ def test_options_write (self ):
22
+ response = requests .get (self .url_options )
23
+ self .assertEqual (response .status_code , 200 )
24
+
25
+ pre_value = response .json ()["send_seed" ]
26
+
27
+ self .assertEqual (requests .post (self .url_options , json = {"send_seed" :not pre_value }).status_code , 200 )
28
+
29
+ response = requests .get (self .url_options )
30
+ self .assertEqual (response .status_code , 200 )
31
+ self .assertEqual (response .json ()["send_seed" ], not pre_value )
32
+
33
+ requests .post (self .url_options , json = {"send_seed" : pre_value })
34
+
35
+ def test_cmd_flags (self ):
36
+ self .assertEqual (requests .get (self .url_cmd_flags ).status_code , 200 )
37
+
38
+ def test_samplers (self ):
39
+ self .assertEqual (requests .get (self .url_samplers ).status_code , 200 )
40
+
41
+ def test_upscalers (self ):
42
+ self .assertEqual (requests .get (self .url_upscalers ).status_code , 200 )
43
+
44
+ def test_sd_models (self ):
45
+ self .assertEqual (requests .get (self .url_sd_models ).status_code , 200 )
46
+
47
+ def test_hypernetworks (self ):
48
+ self .assertEqual (requests .get (self .url_hypernetworks ).status_code , 200 )
49
+
50
+ def test_face_restorers (self ):
51
+ self .assertEqual (requests .get (self .url_face_restorers ).status_code , 200 )
52
+
53
+ def test_realesrgan_models (self ):
54
+ self .assertEqual (requests .get (self .url_realesrgan_models ).status_code , 200 )
55
+
56
+ def test_prompt_styles (self ):
57
+ self .assertEqual (requests .get (self .url_prompt_styles ).status_code , 200 )
58
+
59
+ def test_artist_categories (self ):
60
+ self .assertEqual (requests .get (self .url_artist_categories ).status_code , 200 )
61
+
62
+ def test_artists (self ):
63
+ self .assertEqual (requests .get (self .url_artists ).status_code , 200 )
0 commit comments