Test completion quickmark/bookmark deletion.
Validate that quickmarks and bookmarks can be deleted from the url completion menu.
This commit is contained in:
parent
409de10fb4
commit
b6652ad6bc
@ -201,7 +201,7 @@ def host_blocker_stub(stubs):
|
|||||||
@pytest.yield_fixture
|
@pytest.yield_fixture
|
||||||
def quickmark_manager_stub(stubs):
|
def quickmark_manager_stub(stubs):
|
||||||
"""Fixture which provides a fake quickmark manager object."""
|
"""Fixture which provides a fake quickmark manager object."""
|
||||||
stub = stubs.UrlMarkManagerStub()
|
stub = stubs.QuickmarkManagerStub()
|
||||||
objreg.register('quickmark-manager', stub)
|
objreg.register('quickmark-manager', stub)
|
||||||
yield stub
|
yield stub
|
||||||
objreg.delete('quickmark-manager')
|
objreg.delete('quickmark-manager')
|
||||||
@ -210,7 +210,7 @@ def quickmark_manager_stub(stubs):
|
|||||||
@pytest.yield_fixture
|
@pytest.yield_fixture
|
||||||
def bookmark_manager_stub(stubs):
|
def bookmark_manager_stub(stubs):
|
||||||
"""Fixture which provides a fake bookmark manager object."""
|
"""Fixture which provides a fake bookmark manager object."""
|
||||||
stub = stubs.UrlMarkManagerStub()
|
stub = stubs.BookmarkManagerStub()
|
||||||
objreg.register('bookmark-manager', stub)
|
objreg.register('bookmark-manager', stub)
|
||||||
yield stub
|
yield stub
|
||||||
objreg.delete('bookmark-manager')
|
objreg.delete('bookmark-manager')
|
||||||
|
@ -474,6 +474,19 @@ class UrlMarkManagerStub(QObject):
|
|||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self.marks = {}
|
self.marks = {}
|
||||||
|
|
||||||
|
def delete(self, key):
|
||||||
|
del self.marks[key]
|
||||||
|
self.removed.emit(key)
|
||||||
|
|
||||||
|
|
||||||
|
class BookmarkManagerStub(UrlMarkManagerStub):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class QuickmarkManagerStub(UrlMarkManagerStub):
|
||||||
|
def quickmark_del(self, key):
|
||||||
|
self.delete(key)
|
||||||
|
|
||||||
|
|
||||||
class WebHistoryStub(QObject):
|
class WebHistoryStub(QObject):
|
||||||
|
|
||||||
|
@ -177,6 +177,51 @@ def test_url_completion(config_stub, web_history, quickmarks, bookmarks):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def test_url_completion_delete_bookmark(config_stub, web_history, quickmarks,
|
||||||
|
bookmarks):
|
||||||
|
"""Test deleting a bookmark from the url completion model."""
|
||||||
|
config_stub.data['completion'] = {'timestamp-format': '%Y-%m-%d',
|
||||||
|
'web-history-max-items': 2}
|
||||||
|
model = urlmodel.UrlCompletionModel()
|
||||||
|
index = Mock()
|
||||||
|
cat = Mock()
|
||||||
|
completion_widget = Mock()
|
||||||
|
index.isValid = Mock(return_value=True)
|
||||||
|
index.parent = Mock(return_value=cat)
|
||||||
|
index.data = Mock(return_value='https://github.com')
|
||||||
|
cat.child = Mock(return_value=index)
|
||||||
|
cat.data = Mock(return_value='Bookmarks')
|
||||||
|
completion_widget.currentIndex = Mock(return_value=index)
|
||||||
|
model.delete_cur_item(completion_widget)
|
||||||
|
assert 'https://github.com' not in bookmarks.marks
|
||||||
|
assert 'https://python.org' in bookmarks.marks
|
||||||
|
assert 'http://qutebrowser.org' in bookmarks.marks
|
||||||
|
|
||||||
|
|
||||||
|
def test_url_completion_delete_quickmark(config_stub, web_history, quickmarks,
|
||||||
|
bookmarks):
|
||||||
|
"""Test deleting a bookmark from the url completion model."""
|
||||||
|
config_stub.data['completion'] = {'timestamp-format': '%Y-%m-%d',
|
||||||
|
'web-history-max-items': 2}
|
||||||
|
model = urlmodel.UrlCompletionModel()
|
||||||
|
index = Mock()
|
||||||
|
sibling = Mock()
|
||||||
|
cat = Mock()
|
||||||
|
completion_widget = Mock()
|
||||||
|
index.isValid = Mock(return_value=True)
|
||||||
|
index.parent = Mock(return_value=cat)
|
||||||
|
index.sibling = Mock(return_value=sibling)
|
||||||
|
sibling.isValid = Mock(return_value=True)
|
||||||
|
sibling.data = Mock(return_value='ddg')
|
||||||
|
cat.child = Mock(return_value=index)
|
||||||
|
cat.data = Mock(return_value='Quickmarks')
|
||||||
|
completion_widget.currentIndex = Mock(return_value=index)
|
||||||
|
model.delete_cur_item(completion_widget)
|
||||||
|
assert 'aw' in quickmarks.marks
|
||||||
|
assert 'ddg' not in quickmarks.marks
|
||||||
|
assert 'wiki' in quickmarks.marks
|
||||||
|
|
||||||
|
|
||||||
def test_session_completion(session_manager_stub):
|
def test_session_completion(session_manager_stub):
|
||||||
session_manager_stub.sessions = ['default', '1', '2']
|
session_manager_stub.sessions = ['default', '1', '2']
|
||||||
actual = _get_completions(miscmodels.SessionCompletionModel())
|
actual = _get_completions(miscmodels.SessionCompletionModel())
|
||||||
|
Loading…
Reference in New Issue
Block a user