Fix pylint and coverage for history.

This commit is contained in:
Ryan Roden-Corrent 2017-08-20 20:43:31 -04:00
parent 8c6133e29d
commit 5f45b9b40e
2 changed files with 11 additions and 1 deletions

View File

@ -48,7 +48,7 @@ class WebHistory(sql.SqlTable):
super().__init__("History", ['url', 'title', 'atime', 'redirect'],
parent=parent)
self.completion = CompletionHistory(parent=self)
if len(self.completion) == 0:
if not self.completion:
self._rebuild_completion()
self.create_index('HistoryIndex', 'url')
self.create_index('HistoryAtimeIndex', 'atime')

View File

@ -367,3 +367,13 @@ def test_rebuild_completion(hist):
('example.com/1', '', 2),
('example.com/2 3', '', 3),
]
def test_no_rebuild_completion(hist):
"""Ensure that completion is not regenerated unless completely empty."""
hist.add_url(QUrl('example.com/1'), redirect=False, atime=1)
hist.add_url(QUrl('example.com/2'), redirect=False, atime=2)
hist.completion.delete('url', 'example.com/2')
hist2 = history.WebHistory()
assert list(hist2.completion) == [('example.com/1', '', 1)]