def test_set_current_document_view(): ac = Application() m = Mocker() dv = m.mock(TextDocumentView) ac.find_editor_with_document_view = m.method(ac.find_editor_with_document_view) ed = ac.find_editor_with_document_view(dv) >> m.mock(Editor) ed.current_view = dv with m: ac.set_current_document_view(dv)
def test_set_current_document_view(): ac = Application() m = Mocker() dv = m.mock(TextDocumentView) ac.find_editor_with_document_view = m.method( ac.find_editor_with_document_view) ed = ac.find_editor_with_document_view(dv) >> m.mock(Editor) ed.current_view = dv with m: ac.set_current_document_view(dv)
def test(config): """Test argument structure: [ # collection of window controllers [ # window controller / collection of projects ["doc1", "doc2", "doc3", ...], # project / collection of documents ... ] ... ] """ result = None ac = Application() m = Mocker() dv = m.mock(TextDocumentView) # this is the view we're looking for document = m.mock(TextDocument) (dv.document << document).count(0, None) ac.iter_editors = m.method(ac.iter_editors) eds = ac.iter_editors() >> [] for ed_projects in config: ed = m.mock(Editor) eds.append(ed) projects = [] ed.projects >> projects found = False for project_documents in ed_projects: project = m.mock(Project) projects.append(project) documents = [] if not found: project.documents() >> documents for doc_name in project_documents: if doc_name == DOC: documents.append(dv) result = ed found = True else: documents.append(m.mock(TextDocumentView)) with m: ed = ac.find_editor_with_document_view(dv) eq_(ed, result)
def test(config): """Test argument structure: [ # collection of window controllers [ # window controller / collection of projects ["doc1", "doc2", "doc3", ...], # project / collection of documents ... ] ... ] """ result = None ac = Application() m = Mocker() dv = m.mock(TextDocumentView) # this is the view we're looking for document = m.mock(TextDocument) (dv.document << document).count(0, None) ac.iter_editors = m.method(ac.iter_editors) eds = ac.iter_editors() >> [] for ed_projects in config: ed = m.mock(Editor) eds.append(ed) projects = [] ed.projects >> projects found = False for project_documents in ed_projects: project = m.mock(Project) projects.append(project) documents = [] if not found: project.documents() >> documents for doc_name in project_documents: if doc_name == DOC: documents.append(dv) result = ed found = True else: documents.append(m.mock(TextDocumentView)) with m: ed = ac.find_editor_with_document_view(dv) eq_(ed, result)