mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-18 05:28:16 -06:00
Update tests
This commit is contained in:
parent
5d8d5b2ae2
commit
25a0e06720
@ -39,6 +39,8 @@ REDIS = {
|
||||
|
||||
SECRET_KEY = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
|
||||
|
||||
DJANGO_ADMIN_ENABLED = True
|
||||
|
||||
DEFAULT_PERMISSIONS = {}
|
||||
|
||||
LOGGING = {
|
||||
|
@ -4,23 +4,23 @@ from netbox.plugins.navigation import PluginMenu, PluginMenuButton, PluginMenuIt
|
||||
|
||||
items = (
|
||||
PluginMenuItem(
|
||||
link='plugins:dummy_plugin:dummy_models',
|
||||
link='plugins:dummy_plugin:dummy_model_list',
|
||||
link_text='Item 1',
|
||||
buttons=(
|
||||
PluginMenuButton(
|
||||
link='admin:dummy_plugin_dummymodel_add',
|
||||
title='Add a new dummy model',
|
||||
link='plugins:dummy_plugin:dummy_model_add',
|
||||
title='Button 1',
|
||||
icon_class='mdi mdi-plus-thick',
|
||||
),
|
||||
PluginMenuButton(
|
||||
link='admin:dummy_plugin_dummymodel_add',
|
||||
title='Add a new dummy model',
|
||||
link='plugins:dummy_plugin:dummy_model_add',
|
||||
title='Button 2',
|
||||
icon_class='mdi mdi-plus-thick',
|
||||
),
|
||||
)
|
||||
),
|
||||
PluginMenuItem(
|
||||
link='plugins:dummy_plugin:dummy_models',
|
||||
link='plugins:dummy_plugin:dummy_model_list',
|
||||
link_text='Item 2',
|
||||
),
|
||||
)
|
||||
|
@ -4,5 +4,6 @@ from . import views
|
||||
|
||||
|
||||
urlpatterns = (
|
||||
path('models/', views.DummyModelsView.as_view(), name='dummy_models'),
|
||||
path('models/', views.DummyModelsView.as_view(), name='dummy_model_list'),
|
||||
path('models/add/', views.DummyModelAddView.as_view(), name='dummy_model_add'),
|
||||
)
|
||||
|
@ -1,3 +1,6 @@
|
||||
import random
|
||||
import string
|
||||
|
||||
from django.http import HttpResponse
|
||||
from django.views.generic import View
|
||||
|
||||
@ -15,6 +18,20 @@ class DummyModelsView(View):
|
||||
return HttpResponse(f"Instances: {instance_count}")
|
||||
|
||||
|
||||
class DummyModelAddView(View):
|
||||
|
||||
def get(self, request):
|
||||
return HttpResponse(f"Create an instance")
|
||||
|
||||
def post(self, request):
|
||||
instance = DummyModel(
|
||||
name=''.join(random.choices(string.ascii_lowercase, k=8)),
|
||||
number=random.randint(1, 100000)
|
||||
)
|
||||
instance.save()
|
||||
return HttpResponse(f"Instance created")
|
||||
|
||||
|
||||
@register_model_view(Site, 'extra', path='other-stuff')
|
||||
class ExtraCoreModelView(View):
|
||||
|
||||
|
@ -32,7 +32,6 @@ class PluginTest(TestCase):
|
||||
instance.delete()
|
||||
self.assertIsNone(instance.pk)
|
||||
|
||||
@override_settings(DJANGO_ADMIN_ENABLED=True)
|
||||
def test_admin(self):
|
||||
|
||||
# Test admin view URL resolution
|
||||
@ -42,7 +41,7 @@ class PluginTest(TestCase):
|
||||
def test_views(self):
|
||||
|
||||
# Test URL resolution
|
||||
url = reverse('plugins:dummy_plugin:dummy_models')
|
||||
url = reverse('plugins:dummy_plugin:dummy_model_list')
|
||||
self.assertEqual(url, '/plugins/dummy-plugin/models/')
|
||||
|
||||
# Test GET request
|
||||
|
Loading…
Reference in New Issue
Block a user