File size: 1,080 Bytes
3f9c56c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import unittest
import importlib
utils = importlib.import_module('extensions.sd-webui-controlnet.tests.utils', 'utils')
utils.setup_test_env()

from scripts import external_code


class TestGetAllUnitsFrom(unittest.TestCase):
    def setUp(self):
        self.control_unit = {
            "module": "none",
            "model": utils.get_model(),
            "image": utils.readImage("test/test_files/img2img_basic.png"),
            "resize_mode": 1,
            "low_vram": False,
            "processor_res": 64,
            "control_mode": external_code.ControlMode.BALANCED.value,
        }
        self.object_unit = external_code.ControlNetUnit(**self.control_unit)

    def test_empty_converts(self):
        script_args = []
        units = external_code.get_all_units_from(script_args)
        self.assertListEqual(units, [])

    def test_object_forwards(self):
        script_args = [self.object_unit]
        units = external_code.get_all_units_from(script_args)
        self.assertListEqual(units, [self.object_unit])


if __name__ == '__main__':
    unittest.main()