コード例 #1
0
    def test_show_all_docs_info_3(self, mocked_show_document_info):

        app.show_all_docs_info()

        mocked_show_document_info.called
        calls = mocked_show_document_info.call_count
        self.assertEqual(calls, len(app.documents))
コード例 #2
0
ファイル: mytest.py プロジェクト: VengAniRi/D.Z_2.4
 def test_show_all_docs_info(self):
     correct_answer = 'Список всех документов:\n\n' \
                    'passport "2207 876234" "Василий Гупкин"\n' \
                    'invoice "11-2" "Геннадий Покемонов"\n' \
                    'insurance "10006" "Аристарх Павлов"\n'
     with patch('sys.stdout', new=StringIO()) as fake_out:
         app.show_all_docs_info()
         self.assertEqual(fake_out.getvalue(), correct_answer)
コード例 #3
0
    def test_show_all_docs_info_2(self, mocked_print):
        calls = [call('Список всех документов:\n')]

        for doc in app.documents:
            doc_type = doc['type']
            doc_number = doc['number']
            doc_owner = doc['name']
            calls.append(call(f'{doc_type} "{doc_number}" "{doc_owner}"'))

        app.show_all_docs_info()
        mocked_print.assert_has_calls(calls)
コード例 #4
0
    def test_show_all_docs_info(self):
        with patch('sys.stdout', new=io.StringIO()) as main_fake_stdout:
            app.show_all_docs_info()

        f_stdout = '\n'
        for doc in app.documents:
            doc_type = doc['type']
            doc_number = doc['number']
            doc_owner = doc['name']

            with patch('sys.stdout', new=io.StringIO()) as fake_stdout:
                app.show_document_info(doc)
            f_stdout += fake_stdout.getvalue()
            assert fake_stdout.getvalue(
            ) == f'{doc_type} "{doc_number}" "{doc_owner}"\n'

        assert main_fake_stdout.getvalue(
        ) == 'Список всех документов:\n' + f_stdout
コード例 #5
0
 def test_show_info(self):
     app.show_all_docs_info()
コード例 #6
0
 def test_show_all_docs_info(self):
     docs_from_documents = [
         f'{doc["type"]} "{doc["number"]}" "{doc["name"]}"'
         for doc in app.documents
     ]
     self.assertEqual(app.show_all_docs_info(), docs_from_documents)