Skip to content

Commit

Permalink
Merge pull request #311 from itdependsnetworks/stable-1.1-cp
Browse files Browse the repository at this point in the history
Prep stable1.1 with cherry-picked commits
  • Loading branch information
itdependsnetworks authored Aug 12, 2022
2 parents e5599a2 + 9debe38 commit 6653145
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## v1.1.1 - 2022-09

### Fixed

- #260 Server Error when viewing Compliance Report <Overview>: Cherry picked
- #309 Fix duplicate entries on home view: Cherry picked

## v1.1.0 - 2022-07

### Announcements
Expand Down
46 changes: 46 additions & 0 deletions nautobot_golden_config/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""Unit tests for nautobot_golden_config views."""

from django.test import TestCase

from nautobot.dcim.models import Device
from nautobot_golden_config import views, models

from .conftest import create_feature_rule_json, create_device_data


class ConfigComplianceOverviewOverviewHelperTestCase(TestCase):
"""Test ConfigComplianceOverviewOverviewHelper."""

def setUp(self):
"""Set up base objects."""
create_device_data()
dev01 = Device.objects.get(name="Device 1")
dev02 = Device.objects.get(name="Device 2")
dev03 = Device.objects.get(name="Device 3")
dev04 = Device.objects.get(name="Device 4")

feature_dev01 = create_feature_rule_json(dev01)
feature_dev02 = create_feature_rule_json(dev02)
feature_dev03 = create_feature_rule_json(dev03)

updates = [
{"device": dev01, "feature": feature_dev01},
{"device": dev02, "feature": feature_dev02},
{"device": dev03, "feature": feature_dev03},
{"device": dev04, "feature": feature_dev01},
]
for update in updates:
models.ConfigCompliance.objects.create(
device=update["device"],
rule=update["feature"],
actual={"foo": {"bar-1": "baz"}},
intended={"foo": {"bar-1": "baz"}},
)

self.ccoh = views.ConfigComplianceOverviewOverviewHelper

def test_plot_visual_no_devices(self):

aggr = {"comp_percents": 0, "compliants": 0, "non_compliants": 0, "total": 0}

self.assertEqual(self.ccoh.plot_visual(aggr), None)
5 changes: 3 additions & 2 deletions nautobot_golden_config/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def alter_queryset(self, request):
qs = qs | obj.get_queryset().distinct()

return self.queryset.filter(id__in=qs).annotate(
config_type=F("configcompliance__rule__config_type"),
backup_config=F("goldenconfig__backup_config"),
intended_config=F("goldenconfig__intended_config"),
compliance_config=F("goldenconfig__compliance_config"),
Expand Down Expand Up @@ -509,7 +508,9 @@ def get_required_permission(self):
def plot_visual(aggr):
"""Plot aggregation visual."""
labels = "Compliant", "Non-Compliant"
if aggr["compliants"] is not None:
# Only Compliants and Non-Compliants values are used to create the diagram
# if either of them are True (not 0), create the diagram
if any((aggr["compliants"], aggr["non_compliants"])):
sizes = [aggr["compliants"], aggr["non_compliants"]]
explode = (0, 0.1) # only "explode" the 2nd slice (i.e. 'Hogs')
# colors used for visuals ('compliant','non_compliant')
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nautobot-golden-config"
version = "1.1.0"
version = "1.1.1"
description = "A plugin for configuration on nautobot"
authors = ["Network to Code, LLC", "<[email protected]>"]

Expand Down

0 comments on commit 6653145

Please sign in to comment.