Skip to content

Commit

Permalink
Fix brief test based on Nautobot version.
Browse files Browse the repository at this point in the history
  • Loading branch information
smk4664 committed Sep 6, 2022
1 parent 9e61aa2 commit e3932c2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 16 deletions.
6 changes: 3 additions & 3 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,19 @@ extra:
social:
- icon: "fontawesome/solid/rss"
link: "https://blog.networktocode.com/blog/tags/nautobot"
name: "NetworkToCode Blog"
name: "Network to Code Blog"
- icon: "fontawesome/brands/youtube"
link: "https://www.youtube.com/playlist?list=PLjA0bhxgryJ2Ts4GJMDA-tPzVWEncv4pb"
name: "Nautobot Videos"
- icon: "fontawesome/brands/slack"
link: "https://www.networktocode.com/community/"
name: "NetworkToCode Community"
name: "Network to Code Community"
- icon: "fontawesome/brands/github"
link: "https://github.com/nautobot/nautobot"
name: "GitHub Repo"
- icon: "fontawesome/brands/twitter"
link: "https://twitter.com/networktocode"
name: "NetworkToCode Twitter"
name: "Network to Code Twitter"
markdown_extensions:
- "admonition"
- "toc":
Expand Down
40 changes: 27 additions & 13 deletions nautobot_chatops/tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
"""Test cases for Nautobot Chatops API."""
try:
from importlib import metadata
except ImportError:
# Python version < 3.8
import importlib_metadata as metadata

from django.urls import reverse

from nautobot.utilities.testing import APITestCase, APIViewTestCases
from nautobot_chatops.models import AccessGrant, CommandToken


nautobot_version = metadata.version("nautobot")


class AppTest(APITestCase): # pylint: disable=too-many-ancestors
"""Test cases for the Nautobot_chatops App."""

Expand All @@ -21,7 +29,10 @@ class CommandTokenTest(APIViewTestCases.APIViewTestCase): # pylint: disable=too
"""Tests for the CommandToken Endpoint."""

model = CommandToken
brief_fields = ["comment", "created", "display", "id", "last_updated", "platform", "token", "url"]
brief_fields = ["comment", "display", "id", "platform", "token", "url"]
# Nautobot 1.4.0 added created/last_updated to builtin serializers.
if nautobot_version >= "1.4.0":
brief_fields = ["comment", "created", "display", "id", "last_updated", "platform", "token", "url"]
create_data = [
{"comment": "Test 4", "platform": "mattermost", "token": "token4"},
{"comment": "Test 5", "platform": "mattermost", "token": "token5"},
Expand All @@ -42,18 +53,21 @@ class AccessGrantTest(APIViewTestCases.APIViewTestCase): # pylint: disable=too-
"""Tests for the AccessGrant Endpoint."""

model = AccessGrant
brief_fields = [
"command",
"created",
"display",
"grant_type",
"id",
"last_updated",
"name",
"subcommand",
"url",
"value",
]
brief_fields = ["command", "display", "grant_type", "id", "name", "subcommand", "url", "value"]
# Nautobot 1.4.0 added created/last_updated to builtin serializers.
if nautobot_version >= "1.4.0":
brief_fields = [
"command",
"created",
"display",
"grant_type",
"id",
"last_updated",
"name",
"subcommand",
"url",
"value",
]
create_data = [
{"command": "*", "subcommand": "*", "grant_type": "organization", "name": "test4", "value": "*"},
{"command": "*", "subcommand": "*", "grant_type": "channel", "name": "test5", "value": "*"},
Expand Down

0 comments on commit e3932c2

Please sign in to comment.