Merge pull request #64 from wheresmyjetpack/master

Testing enhancements
This commit is contained in:
Arun Prakash Jana 2016-09-04 11:15:06 +05:30 committed by GitHub
commit 4df5769a1e
2 changed files with 12 additions and 16 deletions

23
buku
View File

@ -446,21 +446,6 @@ class BukuDb:
:tag_manual: string of comma-separated tags to add manually
"""
self.select_tags_from_bookmarks(index)
resultset = self.cur.fetchall()
for row in resultset:
tags = '%s%s' % (row[1], tag_manual[1:])
tags = parse_tags([tags])
self.cur.execute('UPDATE bookmarks SET tags = ? WHERE id = ?', (tags, row[0],))
self.conn.commit()
def select_tags_from_bookmarks(self, index):
""" Select either the tags for one bookmark or all bookmarks
:param index: int position of record, 0 for all
"""
if index == 0:
resp = input('Tags will be appended for ALL bookmarks. Enter \x1b[1my\x1b[21m to confirm: ')
if resp != 'y':
@ -470,6 +455,14 @@ class BukuDb:
else:
self.cur.execute('SELECT id, tags FROM bookmarks WHERE id = ?', (index,))
resultset = self.cur.fetchall()
for row in resultset:
tags = '%s%s' % (row[1], tag_manual[1:])
tags = parse_tags([tags])
self.cur.execute('UPDATE bookmarks SET tags = ? WHERE id = ?', (tags, row[0],))
self.conn.commit()
def delete_tag_at_index(self, index, tag_manual):
""" Delete tags for bookmark at index

View File

@ -265,9 +265,12 @@ class TestBukuDb(unittest.TestCase):
# deleting all bookmarks
self.bdb.delete_all_bookmarks()
# assert table has been dropped
with self.assertRaises(sqlite3.OperationalError):
with self.assertRaises(sqlite3.OperationalError) as ctx_man:
self.bdb.get_bookmark_by_index(0)
err_msg = str(ctx_man.exception)
self.assertEqual(err_msg, 'no such table: bookmarks')
# @unittest.skip('skipping')
def test_replace_tag(self):
indices = []