Unit test session completion

This commit is contained in:
Ryan Roden-Corrent 2016-06-16 23:12:04 -04:00
parent baf8d00a20
commit 610f9b7068
3 changed files with 28 additions and 0 deletions

View File

@ -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."""

View File

@ -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

View File

@ -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.