mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Docs and test for #9072
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
from django.http import HttpResponse
|
||||
from django.views.generic import View
|
||||
|
||||
from dcim.models import Site
|
||||
from utilities.views import register_model_view
|
||||
from .models import DummyModel
|
||||
|
||||
|
||||
@@ -9,3 +11,10 @@ class DummyModelsView(View):
|
||||
def get(self, request):
|
||||
instance_count = DummyModel.objects.count()
|
||||
return HttpResponse(f"Instances: {instance_count}")
|
||||
|
||||
|
||||
@register_model_view(Site, 'extra', path='other-stuff')
|
||||
class ExtraCoreModelView(View):
|
||||
|
||||
def get(self, request, pk):
|
||||
return HttpResponse("Success!")
|
||||
|
@@ -59,6 +59,17 @@ class PluginTest(TestCase):
|
||||
response = client.get(url)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_registered_views(self):
|
||||
|
||||
# Test URL resolution
|
||||
url = reverse('dcim:site_extra', kwargs={'pk': 1})
|
||||
self.assertEqual(url, '/dcim/sites/1/other-stuff/')
|
||||
|
||||
# Test GET request
|
||||
client = Client()
|
||||
response = client.get(url)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_menu(self):
|
||||
"""
|
||||
Check menu registration.
|
||||
|
Reference in New Issue
Block a user