MCPcopy Create free account
hub / github.com/dbcli/mycli / output

Function output

test/pytests/test_main.py:788–833  ·  view source on GitHub ↗
(monkeypatch, terminal_size, testdata, explicit_pager, expect_pager)

Source from the content-addressed store, hash-verified

786
787
788def output(monkeypatch, terminal_size, testdata, explicit_pager, expect_pager):
789 global clickoutput
790 clickoutput = ""
791 m = MyCli(myclirc=default_config_file)
792
793 class TestOutput:
794 def get_size(self):
795 size = namedtuple("Size", "rows columns")
796 size.columns, size.rows = terminal_size
797 return size
798
799 class TestExecute:
800 host = "test"
801 user = "test"
802 dbname = "test"
803 server_info = ServerInfo.from_version_string("unknown")
804 port = 0
805 socket = ''
806
807 def server_type(self):
808 return ["test"]
809
810 class TestPromptSession:
811 output = TestOutput()
812 app = None
813
814 m.prompt_session = TestPromptSession()
815 m.sqlexecute = TestExecute()
816 m.explicit_pager = explicit_pager
817
818 def echo_via_pager(s):
819 assert expect_pager
820 global clickoutput
821 clickoutput += "".join(s)
822
823 def secho(s):
824 assert not expect_pager
825 global clickoutput
826 clickoutput += s + "\n"
827
828 monkeypatch.setattr(click, "echo_via_pager", echo_via_pager)
829 monkeypatch.setattr(click, "secho", secho)
830 m.output(testdata, SQLResult())
831 if clickoutput.endswith("\n"):
832 clickoutput = clickoutput[:-1]
833 assert clickoutput == "\n".join(testdata)
834
835
836def test_conditional_pager(monkeypatch):

Callers 1

test_conditional_pagerFunction · 0.70

Calls 6

SQLResultClass · 0.90
MyCliClass · 0.85
TestPromptSessionClass · 0.85
TestExecuteClass · 0.85
outputMethod · 0.80
joinMethod · 0.80

Tested by

no test coverage detected