File tree 1 file changed +22
-1
lines changed
openwisp_controller/config/tests
1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 9
9
from uuid import uuid4
10
10
11
11
from django .db .utils import DEFAULT_DB_ALIAS
12
+ from django .http import HttpResponse
12
13
from openwisp_ipam .tests import CreateModelsMixin as CreateIpamModelsMixin
13
14
from swapper import load_model
14
15
25
26
Cert = load_model ('django_x509' , 'Cert' )
26
27
27
28
29
+ class TestUtilsMixin :
30
+ """
31
+ Mixin for testing utility functions from utils.py
32
+ """
33
+ def _create_http_request (self , ip = '127.0.0.1' , management_ip = None ):
34
+ class MockRequest :
35
+ META = {'REMOTE_ADDR' : ip }
36
+ GET = {}
37
+
38
+ request = MockRequest ()
39
+ if management_ip :
40
+ request .GET ['management_ip' ] = management_ip
41
+ return request
42
+
43
+ def _create_controller_response (self , content = '' , content_type = 'text/plain' , status = 200 ):
44
+ response = HttpResponse (content , content_type = content_type , status = status )
45
+ response ['X-Openwisp-Controller' ] = 'true'
46
+ return response
47
+
48
+
28
49
class CreateDeviceMixin (TestOrganizationMixin ):
29
50
TEST_MAC_ADDRESS = '00:11:22:33:44:55'
30
51
@@ -408,4 +429,4 @@ def _create_device_group(self, **kwargs):
408
429
device_group = DeviceGroup (** options )
409
430
device_group .full_clean ()
410
431
device_group .save ()
411
- return device_group
432
+ return device_group
You can’t perform that action at this time.
0 commit comments