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_raise_exception_entry(self):
# Entries name collision exception
unique_str = 'test_add_entry_'
entry = self.kp.add_entry(
self.kp.root_group,
unique_str + 'title',
unique_str + 'user',
unique_str + 'pass',
url=unique_str + 'url',
notes=unique_str + 'notes',
tags=unique_str + 'tags',
icon=icons.KEY
)
self.assertRaises(Exception, entry)
expires=True,
expiry_time=time,
icon=icons.KEY,
kp=self.kp
)
self.assertEqual(entry.title, 'title')
self.assertEqual(entry.username, 'username')
self.assertEqual(entry.password, 'password')
self.assertEqual(entry.url, 'url')
self.assertEqual(entry.notes, 'notes')
self.assertEqual(entry.tags, ['tags'])
self.assertEqual(entry.expires, True)
self.assertEqual(entry.expiry_time,
time.replace(tzinfo=tz.gettz()).astimezone(tz.gettz('UTC')))
self.assertEqual(entry.icon, icons.KEY)
self.assertEqual(entry.is_a_history_entry, False)
self.assertEqual(self.kp.find_entries(title='subentry', first=True).path, 'foobar_group/subgroup/subentry')
self.assertEqual(
self.kp.find_entries(title='root_entry', first=True).history[0].group,
self.kp.root_group
)
def test_add_delete_move_entry(self):
unique_str = 'test_add_entry_'
expiry_time = datetime.now()
entry = self.kp.add_entry(
self.kp.root_group,
unique_str + 'title',
unique_str + 'user',
unique_str + 'pass',
url=unique_str + 'url',
notes=unique_str + 'notes',
tags=unique_str + 'tags',
expiry_time=expiry_time,
icon=icons.KEY
)
results = self.kp.find_entries_by_title(unique_str + 'title')
self.assertEqual(len(results), 1)
results = self.kp.find_entries_by_title(unique_str + 'title', first=True)
self.assertEqual(results.title, unique_str + 'title')
self.assertEqual(results.username, unique_str + 'user')
self.assertEqual(results.password, unique_str + 'pass')
self.assertEqual(results.url, unique_str + 'url')
self.assertEqual(results.notes, unique_str + 'notes')
self.assertEqual(results.tags, [unique_str + 'tags'])
self.assertTrue(results.uuid != None)
# convert naive datetime to utc
expiry_time_utc = expiry_time.replace(tzinfo=tz.gettz()).astimezone(tz.gettz('UTC'))
self.assertEqual(results.icon, icons.KEY)