Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_create_delete_binary(self):
with self.assertRaises(BinaryError):
self.kp.delete_binary(999)
with self.assertRaises(BinaryError):
e = self.kp.entries[0]
e.add_attachment(filename='foo.txt', id=123)
e.attachments[0].binary
binary_id = self.kp.add_binary(b'Ronald McDonald Trump')
self.kp.save()
self.open()
self.assertEqual(self.kp.binaries[binary_id], b'Ronald McDonald Trump')
self.assertEqual(len(self.kp.attachments), 1)
num_attach = len(self.kp.binaries)
self.kp.delete_binary(binary_id)
self.kp.save()
self.open()
def test_create_delete_binary(self):
with self.assertRaises(BinaryError):
self.kp.delete_binary(999)
with self.assertRaises(BinaryError):
e = self.kp.entries[0]
e.add_attachment(filename='foo.txt', id=123)
e.attachments[0].binary
binary_id = self.kp.add_binary(b'Ronald McDonald Trump')
self.kp.save()
self.open()
self.assertEqual(self.kp.binaries[binary_id], b'Ronald McDonald Trump')
self.assertEqual(len(self.kp.attachments), 1)
num_attach = len(self.kp.binaries)
self.kp.delete_binary(binary_id)
self.kp.save()
self.open()
self.assertEqual(len(self.kp.binaries), num_attach - 1)
def binary(self):
try:
return self._kp.binaries[self.id]
except IndexError:
raise BinaryError('No such binary with id {}'.format(self.id))