fixing tests

This commit is contained in:
poikjhn 2016-06-08 10:16:09 +02:00
parent 08543af540
commit 3e395b00e0

View File

@ -29,19 +29,19 @@ class TestBukuDb(unittest.TestCase):
self.bookmarks = [ ['http://slashdot.org', self.bookmarks = [ ['http://slashdot.org',
'SLASHDOT', 'SLASHDOT',
parse_tags(['old', 'news']), parse_tags(['old,news']),
"News for old nerds, stuff that doesn't matter", "News for old nerds, stuff that doesn't matter",
], ],
['http://www.zażółćgęśląjaźń.pl/', ['http://www.zażółćgęśląjaźń.pl/',
'ZAŻÓŁĆ', 'ZAŻÓŁĆ',
parse_tags(['zażółć', 'gęślą', 'jaźń']), parse_tags(['zażółć,gęślą,jaźń']),
"Testing UTF-8, zażółć gęślą jaźń.", "Testing UTF-8, zażółć gęślą jaźń.",
], ],
['https://test.com:8080', ['https://test.com:8080',
'test', 'test',
parse_tags(['test', 'tes', 'est', 'es']), parse_tags(['test,tes,est,es']),
"a case for replace_tag test", "a case for replace_tag test",
], ],
] ]
@ -133,24 +133,11 @@ class TestBukuDb(unittest.TestCase):
# @unittest.skip('skipping') # @unittest.skip('skipping')
def test_refreshdb(self): def test_refreshdb(self):
bdb = BukuDb() bdb = BukuDb()
indices = []
for bookmark in self.bookmarks:
# adding bookmark, getting index
bdb.add_bookmark(*bookmark)
index = bdb.get_bookmark_index(bookmark[0])
indices += [index]
# refreshing bookmark, comparing values
bdb.refreshdb(index, "__refresh_01")
from_db = bdb.get_bookmark_by_index(index)
self.assertEqual(from_db[2], "__refresh_01")
# refreshing all bookmarks (index 0) bdb.add_bookmark("https://www.google.com/ncr", "?")
bdb.refreshdb(0, "__refresh_02") bdb.refreshdb(1)
for index in indices: from_db = bdb.get_bookmark_by_index(1)
from_db = bdb.get_bookmark_by_index(index) self.assertEqual(from_db[2], "Google")
self.assertEqual(from_db[2], "__refresh_02")
# TODO: test refreshdb without title_manual (url fetch)
# def test_searchdb(self): # def test_searchdb(self):
# self.fail() # self.fail()
@ -192,7 +179,7 @@ class TestBukuDb(unittest.TestCase):
indices += [index] indices += [index]
# replacing tags # replacing tags
bdb.replace_tag("news", ["__01"]) bdb.replace_tag("news", ["__01"])
bdb.replace_tag("zażółć", ["__02", "__03"]) bdb.replace_tag("zażółć", ["__02,__03"])
# replacing tag which is also a substring of other tag # replacing tag which is also a substring of other tag
bdb.replace_tag("es", ["__04"]) bdb.replace_tag("es", ["__04"])
# removing tags # removing tags
@ -211,9 +198,9 @@ class TestBukuDb(unittest.TestCase):
if title == "SLASHDOT": if title == "SLASHDOT":
self.assertEqual(from_db[3], parse_tags(["__01"])) self.assertEqual(from_db[3], parse_tags(["__01"]))
elif title == "ZAŻÓŁĆ": elif title == "ZAŻÓŁĆ":
self.assertEqual(from_db[3], parse_tags(["__02", "__03", "jaźń"])) self.assertEqual(from_db[3], parse_tags(["__02,__03,jaźń"]))
elif title == "test": elif title == "test":
self.assertEqual(from_db[3], parse_tags(["test", "tes", "est", "__04"])) self.assertEqual(from_db[3], parse_tags(["test,tes,est,__04"]))
# def test_browse_by_index(self): # def test_browse_by_index(self):
# self.fail() # self.fail()