Skip to content

Commit

Permalink
test: ♻️ Update test for NautobotSubnet.create() to include tags and …
Browse files Browse the repository at this point in the history
…CustomFields.
  • Loading branch information
jdrew82 committed Apr 23, 2024
1 parent 2a3f05c commit cfc0a73
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_create(self):
"""Validate the NautobotVRFGroup create() method creates a VRF."""
self.vrf.delete()
ids = {"name": "Test"}
attrs = {"description": "Test VRF", "tags": ["test"], "custom_fields": {"Dept": {"key": "Dept", "value": "IT"}}}
attrs = {"description": "Test VRF", "tags": ["est"], "custom_fields": {"Dept": {"key": "Dept", "value": "IT"}}}
result = ipam.NautobotVRFGroup.create(self.diffsync, ids, attrs)
self.assertIsInstance(result, ipam.NautobotVRFGroup)
self.diffsync.job.logger.info.assert_called_once_with("Creating VRF Test.")
Expand Down Expand Up @@ -114,14 +114,16 @@ def test_create(self):
"""Validate the NautobotSubnet create() method creates a Prefix."""
self.prefix.delete()
ids = {"network": "10.0.0.0", "mask_bits": "24", "vrf": "Test"}
attrs = {"description": "", "tags": [], "custom_fields": {}}
attrs = {"description": "", "tags": ["Test"], "custom_fields": {"Test": {"key": "Test", "value": "test"}}}
result = ipam.NautobotSubnet.create(self.diffsync, ids, attrs)
self.assertIsInstance(result, ipam.NautobotSubnet)
self.diffsync.job.logger.info.assert_called_once_with("Creating Prefix 10.0.0.0/24 in VRF Test.")
subnet = Prefix.objects.get(prefix=f"{ids['network']}/{ids['mask_bits']}", namespace=self.test_ns)
self.assertEqual(str(subnet.prefix), f"{ids['network']}/{ids['mask_bits']}")
self.assertEqual(self.diffsync.prefix_map["Test"][f"{ids['network']}/{ids['mask_bits']}"], subnet.id)
self.assertEqual(subnet.vrfs.all().first(), self.test_vrf)
self.assertEqual(list(subnet.tags.names()), attrs["tags"])
self.assertEqual(subnet.custom_field_data["Test"], "test")

def test_update(self):
"""Validate the NautobotSubnet update() method updates a Prefix."""
Expand Down

0 comments on commit cfc0a73

Please sign in to comment.