aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_database_v0.py
blob: 0c2c4e23cd065691bb01fb89659ba651c7020348 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from pwman_tstlib import *
initTest(__file__)

import pathlib
from libpwman.database import *

class Test_Database_v0(TestCase):
	"""Legacy version 0 database format.
	"""
	def test_v0(self):
		db = PWManDatabase(filename=pathlib.Path("tests", "test_database_v0.db"),
				   passphrase="test")

		self.assertEqual(db.getCategoryNames(),
				 sorted([ "testcategory", "testcategory2", "testcategory3" ]))

		self.assertEqual(db.getEntryTitles("testcategory"),
				 sorted([ "testtitle", "foo", "biz" ]))
		self.assertEqual(db.getEntryTitles("testcategory2"),
				 sorted([ "testtitle2" ]))
		self.assertEqual(db.getEntryTitles("testcategory3"),
				 sorted([ "testtitle3" ]))

		entry = db.getEntry("testcategory", "testtitle")
		self.assertEqual(entry.user, "testuser")
		self.assertEqual(entry.pw, "testpassword")
		entryBulk = db.getEntryBulk(entry)
		self.assertEqual(entryBulk.data, "testbulk")

		entry = db.getEntry("testcategory", "foo")
		self.assertEqual(entry.user, "bar")
		self.assertEqual(entry.pw, "")
		entryBulk = db.getEntryBulk(entry)
		self.assertIsNone(entryBulk)

		entry = db.getEntry("testcategory", "biz")
		self.assertEqual(entry.user, "baz")
		self.assertEqual(entry.pw, "")
		entryBulk = db.getEntryBulk(entry)
		self.assertIsNone(entryBulk)

		entry = db.getEntry("testcategory2", "testtitle2")
		self.assertEqual(entry.user, "testuser2")
		self.assertEqual(entry.pw, "testpassword2")
		entryBulk = db.getEntryBulk(entry)
		self.assertIsNone(entryBulk)

		entry = db.getEntry("testcategory3", "testtitle3")
		self.assertEqual(entry.user, "testuser3")
		self.assertEqual(entry.pw, "")
		entryBulk = db.getEntryBulk(entry)
		self.assertIsNone(entryBulk)
bues.ch cgit interface