diff --git a/nautobot_golden_config/tests/test_filters.py b/nautobot_golden_config/tests/test_filters.py index 30493286..0dce8982 100644 --- a/nautobot_golden_config/tests/test_filters.py +++ b/nautobot_golden_config/tests/test_filters.py @@ -320,6 +320,8 @@ def setUp(self): self.feature1 = self.rule1.feature self.rule2 = create_feature_rule_cli(self.device2, feature="Feature 2") self.feature2 = self.rule2.feature + self.rule3 = create_feature_rule_cli(self.device1, feature="Feature 3") + self.feature3 = self.rule3.feature self.status1 = Status.objects.get(name="Not Approved") self.status2 = Status.objects.get(name="Approved") self.tag1, _ = Tag.objects.get_or_create(name="Tag 1") @@ -360,7 +362,7 @@ def setUp(self): job_result_id=self.job_result2.id, ) self.config_plan3.tags.add(self.tag2) - self.config_plan3.feature.add(self.feature1) + self.config_plan3.feature.set([self.feature1, self.feature3]) self.config_plan3.validated_save() self.config_plan4 = models.ConfigPlan.objects.create( device=self.device2, diff --git a/nautobot_golden_config/tests/test_models.py b/nautobot_golden_config/tests/test_models.py index d2017676..897f14db 100644 --- a/nautobot_golden_config/tests/test_models.py +++ b/nautobot_golden_config/tests/test_models.py @@ -323,6 +323,28 @@ def test_create_config_plan_intended(self): self.assertEqual(config_plan.status, self.status) self.assertEqual(config_plan.plan_type, "intended") + def test_create_config_plan_intended_multiple_features(self): + """Test Create Object.""" + rule2 = create_feature_rule_json(self.device, feature="feature2") + config_plan = ConfigPlan.objects.create( + device=self.device, + plan_type="intended", + config_set="test intended config", + change_control_id="1234", + change_control_url="https://1234.example.com/", + status=self.status, + job_result_id=self.job_result.id, + ) + config_plan.feature.set([self.feature, rule2.feature]) + config_plan.validated_save() + self.assertEqual(config_plan.device, self.device) + self.assertIn(self.feature.id, config_plan.feature.all().values_list("id", flat=True)) + self.assertIn(rule2.feature.id, config_plan.feature.all().values_list("id", flat=True)) + self.assertEqual(config_plan.config_set, "test intended config") + self.assertEqual(config_plan.change_control_id, "1234") + self.assertEqual(config_plan.status, self.status) + self.assertEqual(config_plan.plan_type, "intended") + def test_create_config_plan_missing(self): """Test Create Object.""" config_plan = ConfigPlan.objects.create( diff --git a/nautobot_golden_config/tests/test_views.py b/nautobot_golden_config/tests/test_views.py index 4eebacca..03757d33 100644 --- a/nautobot_golden_config/tests/test_views.py +++ b/nautobot_golden_config/tests/test_views.py @@ -297,7 +297,7 @@ def test_csv_export_with_filter(self): self.assertEqual(device_names_in_export, device_names_in_site_1) -# pylint: disable=too-many-ancestors +# pylint: disable=too-many-ancestors,too-many-locals class ConfigPlanTestCase( ViewTestCases.GetObjectViewTestCase, ViewTestCases.GetObjectChangelogViewTestCase, @@ -321,6 +321,7 @@ def setUpTestData(cls): rule1 = create_feature_rule_json(device1, feature="Test Feature 1") rule2 = create_feature_rule_json(device2, feature="Test Feature 2") rule3 = create_feature_rule_json(device3, feature="Test Feature 3") + rule4 = create_feature_rule_json(device3, feature="Test Feature 4") job_result1 = create_job_result() job_result2 = create_job_result() @@ -360,7 +361,7 @@ def setUpTestData(cls): status=not_approved_status, job_result_id=job_result3.id, ) - plan3.feature.add(rule3.feature) + plan3.feature.set([rule3.feature, rule4.feature]) plan3.validated_save() # Used for EditObjectViewTestCase