Unit test session completion
This commit is contained in:
parent
baf8d00a20
commit
610f9b7068
@ -225,6 +225,15 @@ def web_history_stub(stubs):
|
||||
objreg.delete('web-history')
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
def session_manager_stub(stubs):
|
||||
"""Fixture which provides a fake web-history object."""
|
||||
stub = stubs.SessionManagerStub()
|
||||
objreg.register('session-manager', stub)
|
||||
yield stub
|
||||
objreg.delete('session-manager')
|
||||
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
def stubs():
|
||||
"""Provide access to stub objects useful for testing."""
|
||||
|
@ -469,3 +469,14 @@ class HostBlockerStub:
|
||||
|
||||
def __init__(self):
|
||||
self.blocked_hosts = set()
|
||||
|
||||
|
||||
class SessionManagerStub:
|
||||
|
||||
"""Stub for the session-manager object."""
|
||||
|
||||
def __init__(self):
|
||||
self.sessions = []
|
||||
|
||||
def list_sessions(self):
|
||||
return self.sessions
|
||||
|
@ -176,6 +176,14 @@ def test_url_completion(config_stub, web_history, quickmarks, bookmarks):
|
||||
]
|
||||
|
||||
|
||||
def test_session_completion(session_manager_stub):
|
||||
session_manager_stub.sessions = ['default', '1', '2']
|
||||
actual = _get_completions(miscmodels.SessionCompletionModel())
|
||||
assert actual == [
|
||||
("Sessions", [('default', '', ''), ('1', '', ''), ('2', '', '')])
|
||||
]
|
||||
|
||||
|
||||
def _get_completions(model):
|
||||
"""Collect all the completion entries of a model, organized by category.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user