Skip to content

Commit

Permalink
refactor: Refactored v1/v2 contrib tests
Browse files Browse the repository at this point in the history
  • Loading branch information
abates committed Jan 26, 2024
1 parent ab99eda commit 597df1a
Show file tree
Hide file tree
Showing 15 changed files with 634 additions and 393 deletions.
2 changes: 2 additions & 0 deletions development/development.env
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ POSTGRES_DB=${NAUTOBOT_DB_NAME}
MYSQL_USER=${NAUTOBOT_DB_USER}
MYSQL_DATABASE=${NAUTOBOT_DB_NAME}
MYSQL_ROOT_HOST=%

DESIGN_BUILDER_ENABLE_BGP=True
31 changes: 24 additions & 7 deletions development/nautobot_config.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
"""Nautobot development configuration file."""
from importlib import metadata
from importlib.util import find_spec
import os
import sys

from packaging.version import Version

from nautobot.core.settings import * # noqa: F403 # pylint: disable=wildcard-import,unused-wildcard-import
from nautobot.core.settings_funcs import is_truthy, parse_redis_connection
from importlib import metadata
from packaging.version import Version

#
# Debug
Expand Down Expand Up @@ -136,11 +138,26 @@
# Apps configuration settings. These settings are used by various Apps that the user may have installed.
# Each key in the dictionary is the name of an installed App and its value is a dictionary of settings.

# TODO: The following is necessary only until BGP models plugin
# is officially supported in 2.0
nautobot_version = Version(Version(metadata.version("nautobot")).base_version)

if nautobot_version < Version("2.0"):
if is_truthy(os.getenv("DESIGN_BUILDER_ENABLE_BGP", "False")):
if find_spec("nautobot_bgp_models") is None:
nautobot_version = Version(Version(metadata.version("nautobot")).base_version)
import subprocess # nosec

package = "nautobot-bgp-models"
if nautobot_version < Version("2.0"):
# pip doesn't have the capability to automatically pick
# a version compatible with the current Nautobot, so we
# do that manually. This is only for development environments
# so that we can run unit tests on Nautobot 1.6 and 2.x
package = "nautobot-bgp-models==0.9.1"
command = [
sys.executable,
"-m",
"pip",
"install",
package,
]
subprocess.check_call(command, shell=False) # nosec
PLUGINS.append("nautobot_bgp_models")

PLUGINS_CONFIG = {"design_builder": {"context_repository": os.getenv("DESIGN_BUILDER_CONTEXT_REPO_SLUG", None)}}
Loading

0 comments on commit 597df1a

Please sign in to comment.