diff --git a/django_netjsonconfig/controller/views.py b/django_netjsonconfig/controller/views.py index 4e0d702..06b3bb5 100644 --- a/django_netjsonconfig/controller/views.py +++ b/django_netjsonconfig/controller/views.py @@ -48,5 +48,9 @@ def register(request): config = Config.objects.create(name=request.POST.get('name'), backend=request.POST.get('backend')) # return id and key in response - content = '{id}\n{key}'.format(**config.__dict__) - return HttpResponse(content, content_type='text/plain', status=201) + s = 'registration-result: success\n' \ + 'uuid: {id}\n' \ + 'key: {key}\n' + return ControllerResponse(s.format(**config.__dict__), + content_type='text/plain', + status=201) diff --git a/django_netjsonconfig/tests/test_controller.py b/django_netjsonconfig/tests/test_controller.py index 1edfc21..87739a3 100644 --- a/django_netjsonconfig/tests/test_controller.py +++ b/django_netjsonconfig/tests/test_controller.py @@ -79,7 +79,10 @@ def test_register(self): 'backend': 'netjsonconfig.OpenWrt' }) self.assertEqual(response.status_code, 201) - uuid, key = response.content.decode().split('\n') + lines = response.content.decode().split('\n') + self.assertEqual(lines[0], 'registration-result: success') + uuid = lines[1].replace('uuid: ', '') + key = lines[2].replace('key: ', '') self.assertEqual(Config.objects.filter(pk=uuid, key=key).count(), 1) def test_register_400(self):