Skip to content

Commit d090a70

Browse files
[BUG] uuid pattern change and pattern checking #682
1 parent d206a7e commit d090a70

File tree

1 file changed

+22
-1
lines changed
  • openwisp_controller/config/tests

1 file changed

+22
-1
lines changed

openwisp_controller/config/tests/utils.py

+22-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from uuid import uuid4
1010

1111
from django.db.utils import DEFAULT_DB_ALIAS
12+
from django.http import HttpResponse
1213
from openwisp_ipam.tests import CreateModelsMixin as CreateIpamModelsMixin
1314
from swapper import load_model
1415

@@ -25,6 +26,26 @@
2526
Cert = load_model('django_x509', 'Cert')
2627

2728

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+
2849
class CreateDeviceMixin(TestOrganizationMixin):
2950
TEST_MAC_ADDRESS = '00:11:22:33:44:55'
3051

@@ -408,4 +429,4 @@ def _create_device_group(self, **kwargs):
408429
device_group = DeviceGroup(**options)
409430
device_group.full_clean()
410431
device_group.save()
411-
return device_group
432+
return device_group

0 commit comments

Comments
 (0)