def test_delete_emptydb(self): d = DeviceAlias(self.switch) d.clear_database() with self.assertRaises(CLIError) as e: d.delete(self.nonexisting) self.assertEqual( 'The command " device-alias database ; no device-alias name ' + str(self.nonexisting) + ' " gave the error " Device Alias not present\nPlease use \'show device-alias session rejected\' to display the rejected set of commands and for the device-alias best-practices recommendation. ".', str(e.exception))
timeout=30, verify_ssl=False, ) # Instantiating DeviceAlias object d = DeviceAlias(sw) # Display the database, mode, distribute, locked print("Device Alias Database") print(d.database) print("Mode : " + d.mode) print("Distribute : " + str(d.distribute)) print("Locked : " + str(d.locked)) old = d.database d.clear_database() # Adding new device alias new = { "device1": "21:00:00:0e:1e:30:34:a5", "device2": "21:00:00:0e:1e:30:3c:c5" } d.create(new) prnt("Clearing database\nDatabase after adding new entry") print(d.database) # Renaming the device alias d.rename("device1", "device_new_name") print("Database after renaming device alias device1 as device_new_name")
def test_clear_database(self): d = DeviceAlias(self.switch) d.clear_database() self.assertIsNone(d.database)