-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #268 from smk4664/next-2.0
v3.0.0rc2
- Loading branch information
Showing
11 changed files
with
99 additions
and
16 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
"""Django urlpatterns declaration for nautobot_chatops.integrations.grafana plugin.""" | ||
|
||
# from django.urls import path | ||
from django.conf import settings | ||
|
||
from nautobot.apps.api import OrderedDefaultRouter | ||
from nautobot_chatops.integrations.grafana.api.views.generic import NautobotPluginChatopsGrafanaRootView | ||
|
||
|
||
urlpatterns = [] | ||
if settings.PLUGINS_CONFIG["nautobot_chatops"]["enable_grafana"]: | ||
router = OrderedDefaultRouter() | ||
router.APIRootView = NautobotPluginChatopsGrafanaRootView | ||
|
||
router = OrderedDefaultRouter() | ||
router.APIRootView = NautobotPluginChatopsGrafanaRootView | ||
app_name = "nautobot_chatops.grafana-api" | ||
|
||
app_name = "nautobot_chatops.grafana-api" | ||
|
||
urlpatterns += router.urls | ||
urlpatterns += router.urls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
"""Tests for the /nautobot chatops commands.""" | ||
from unittest.mock import MagicMock | ||
|
||
from django.contrib.contenttypes.models import ContentType | ||
from django.test import TestCase | ||
from nautobot.dcim.models import Location, LocationType | ||
from nautobot.ipam.models import VLAN | ||
from nautobot.extras.models import Status | ||
from nautobot_chatops.choices import CommandStatusChoices | ||
|
||
from nautobot_chatops.dispatchers import Dispatcher | ||
from nautobot_chatops.workers.nautobot import get_vlans | ||
|
||
|
||
class IpamTestCase(TestCase): | ||
"""Tests related to IPAM ChatOps commands.""" | ||
|
||
def setUp(self): | ||
"""Per-test-case setup function.""" | ||
self.active_status = Status.objects.get(name="Active") | ||
location_type, _ = LocationType.objects.get_or_create(name="Site") | ||
location_type.content_types.add(ContentType.objects.get_for_model(VLAN)) | ||
|
||
self.location = Location.objects.create(location_type=location_type, name="site-1", status=self.active_status) | ||
self.vlans, _ = VLAN.objects.get_or_create( | ||
vid=1, name="vlan-1", status=self.active_status, location=self.location | ||
) | ||
|
||
# Mock the dispatcher | ||
self.dispatcher = MagicMock(Dispatcher) | ||
|
||
def test_get_vlans_initial_prompt(self): | ||
"""Test get VLANs initial command.""" | ||
self.assertFalse(get_vlans(self.dispatcher)) | ||
self.dispatcher.send_error.assert_not_called() | ||
self.dispatcher.prompt_from_menu.assert_called_with( | ||
"nautobot get-vlans", | ||
"select a vlan filter", | ||
[ | ||
("VLAN ID", "id"), | ||
("Group", "group"), | ||
("Name", "name"), | ||
("Role", "role"), | ||
("Location", "location"), | ||
("Status", "status"), | ||
("Tenant", "tenant"), | ||
("All (no filter)", "all"), | ||
], | ||
) | ||
|
||
def test_get_vlans_filter_type_sent_filter_name(self): | ||
"""Test get VLANs with filter type Name selected.""" | ||
self.assertFalse(get_vlans(self.dispatcher, "name")) | ||
self.dispatcher.send_error.assert_not_called() | ||
self.dispatcher.prompt_from_menu.assert_called_with( | ||
"nautobot get-vlans name", "select a vlan name", [("vlan-1", "vlan-1")], offset=0 | ||
) | ||
|
||
def test_get_vlans_filter_type_sent_filter_all(self): | ||
"""Test get VLANs with filter type All selected.""" | ||
self.assertEqual(get_vlans(self.dispatcher, "all"), CommandStatusChoices.STATUS_SUCCEEDED) | ||
self.dispatcher.send_error.assert_not_called() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "nautobot-chatops" | ||
version = "3.0.0rc1" | ||
version = "3.0.0rc2" | ||
description = "A plugin providing chatbot capabilities for Nautobot" | ||
authors = ["Network to Code, LLC <[email protected]>"] | ||
readme = "README.md" | ||
|