Skip to content

Commit

Permalink
test: ✅ Add test validating NautobotSubnet.create() functionality wit…
Browse files Browse the repository at this point in the history
…h setting container type.
  • Loading branch information
jdrew82 committed Nov 15, 2023
1 parent f7bbad2 commit 93ff985
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion nautobot_ssot/tests/device42/unit/test_models_nautobot_ipam.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def setUp(self):
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"}
ids = {"network": "10.0.0.0", "mask_bits": 24, "vrf": "Test"}
attrs = {"description": "", "tags": ["Test"], "custom_fields": {"Test": {"key": "Test", "value": "test"}}}
result = ipam.NautobotSubnet.create(self.diffsync, ids, attrs)
self.assertIsInstance(result, ipam.NautobotSubnet)
Expand All @@ -125,6 +125,16 @@ def test_create(self):
self.assertEqual(list(subnet.tags.names()), attrs["tags"])
self.assertEqual(subnet.custom_field_data["Test"], "test")

def test_create_container_type(self):
"""Validate the NautobotSubnet.create() functionality with setting Prefix to container type."""
self.prefix.delete()
ids = {"network": "0.0.0.0", "mask_bits": 0, "vrf": "Test"} # nosec
attrs = {"description": "", "tags": [], "custom_fields": {}}
result = ipam.NautobotSubnet.create(self.diffsync, ids, attrs)
self.assertIsInstance(result, ipam.NautobotSubnet)
subnet = Prefix.objects.get(prefix=f"{ids['network']}/{ids['mask_bits']}", namespace=self.test_ns)
self.assertEqual(subnet.type, "container")

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

0 comments on commit 93ff985

Please sign in to comment.