def empty_kppy_db(request, tmpdir): assert isinstance(tmpdir, py.path.local) kdb_path = tmpdir.join('test_db.kdb') passpie_keepass.prepare_pycrypto_for_import() from kppy.database import KPDBv1, KPError db = KPDBv1(str(kdb_path), password='******', new=True) def cleanup(): db.close() return db
def kppy_db(self, request, empty_kppy_db): passpie_keepass.prepare_pycrypto_for_import() from kppy.database import KPDBv1, KPError from kppy.groups import v1Group assert isinstance(empty_kppy_db, KPDBv1) assert len(empty_kppy_db.groups) == 1 root_group = empty_kppy_db.groups[0] creation_time = datetime.datetime.utcnow() creation_time = datetime.datetime(*creation_time.utctimetuple()[:6]) empty_kppy_db.mock_creation_time = creation_time creation_time_args = dict( y=creation_time.year, mon=creation_time.month, d=creation_time.day, h=creation_time.hour, min_=creation_time.minute, s=creation_time.second, ) empty_kppy_db.create_entry(group=root_group, title='title_example', comment='comment_example', url='example.com', username='******', password='******', **creation_time_args) empty_kppy_db.create_entry(group=root_group, title='title_google', comment='comment_google', url='google.com', username='******', password='******', **creation_time_args) empty_kppy_db.create_entry(group=root_group, title='title_example', comment='comment_example', url='example.com', username='******', password='******', **creation_time_args) assert empty_kppy_db.create_group(title='group1', parent=root_group, **creation_time_args) group1 = None for g in empty_kppy_db.groups: assert isinstance(g, v1Group) if g.title == 'group1' and g.parent is root_group: group1 = g break assert group1 empty_kppy_db.create_entry(group=group1, title='title_example', comment='comment_example', url='example.com', username='******', password='******', **creation_time_args) empty_kppy_db.create_entry(group=group1, title='title_google', comment='comment_google', url='google.com', username='******', password='******', **creation_time_args) empty_kppy_db.create_entry(group=group1, title='title_example', comment='comment_example', url='example.com', username='******', password='******', **creation_time_args) assert empty_kppy_db.save() return empty_kppy_db
def kppy_db(self, request, empty_kppy_db): passpie_keepass.prepare_pycrypto_for_import() from kppy.database import KPDBv1, KPError from kppy.groups import v1Group assert isinstance(empty_kppy_db, KPDBv1) assert len(empty_kppy_db.groups) == 1 root_group = empty_kppy_db.groups[0] creation_time = datetime.datetime.utcnow() creation_time = datetime.datetime(*creation_time.utctimetuple()[:6]) empty_kppy_db.mock_creation_time = creation_time creation_time_args = dict( y=creation_time.year, mon=creation_time.month, d=creation_time.day, h=creation_time.hour, min_=creation_time.minute, s=creation_time.second, ) empty_kppy_db.create_entry( group=root_group, title='title_example', comment='comment_example', url='example.com', username='******', password='******', **creation_time_args) empty_kppy_db.create_entry( group=root_group, title='title_google', comment='comment_google', url='google.com', username='******', password='******', **creation_time_args) empty_kppy_db.create_entry( group=root_group, title='title_example', comment='comment_example', url='example.com', username='******', password='******', **creation_time_args) assert empty_kppy_db.create_group(title='group1', parent=root_group, **creation_time_args) group1 = None for g in empty_kppy_db.groups: assert isinstance(g, v1Group) if g.title == 'group1' and g.parent is root_group: group1 = g break assert group1 empty_kppy_db.create_entry( group=group1, title='title_example', comment='comment_example', url='example.com', username='******', password='******', **creation_time_args) empty_kppy_db.create_entry( group=group1, title='title_google', comment='comment_google', url='google.com', username='******', password='******', **creation_time_args) empty_kppy_db.create_entry( group=group1, title='title_example', comment='comment_example', url='example.com', username='******', password='******', **creation_time_args) assert empty_kppy_db.save() return empty_kppy_db