Beispiel #1
0
    def test_ensure_device_role_exist(self):
        """Verify ensure_device_role function when DeviceRole exist but is not assigned to the OT."""
        nbk = NetboxKeeper(self.ndk1)

        nbk.ensure_device_role(create_device_role=True,
                               default_device_role="firewall")
        self.assertEqual(nbk.netdev.ot.role, self.device_role1)
Beispiel #2
0
    def test_ensure_device_role_assigned(self):
        """Verify ensure_device_role function when DeviceRole exist and is already assigned."""
        nbk = NetboxKeeper(self.ndk2)

        nbk.ensure_device_role(create_device_role=True,
                               default_device_role="firewall")
        self.assertEqual(nbk.netdev.ot.role, self.device_role1)
Beispiel #3
0
    def test_ensure_device_role_not_exist(self):
        """Verify ensure_device_role function when DeviceRole do not already exist."""
        nbk = NetboxKeeper(self.ndk1)

        with self.assertRaises(OnboardException) as exc_info:
            nbk.ensure_device_role(create_device_role=False, default_device_role="mytestrole")
            self.assertEqual(exc_info.exception.message, "ERROR device role not found: mytestrole")
            self.assertEqual(exc_info.exception.reason, "fail-config")

        nbk.ensure_device_role(create_device_role=True, default_device_role="mytestrole")
        self.assertIsInstance(nbk.netdev.ot.role, DeviceRole)
        self.assertEqual(nbk.netdev.ot.role.slug, "mytestrole")