(monkeypatch)
| 1872 | |
| 1873 | |
| 1874 | def noninteractive_mock_mycli(monkeypatch): |
| 1875 | class Formatter: |
| 1876 | format_name = None |
| 1877 | |
| 1878 | class Logger: |
| 1879 | def debug(self, *args, **args_dict): |
| 1880 | pass |
| 1881 | |
| 1882 | def error(self, *args, **args_dict): |
| 1883 | pass |
| 1884 | |
| 1885 | def warning(self, *args, **args_dict): |
| 1886 | pass |
| 1887 | |
| 1888 | class MockMyCli: |
| 1889 | connect_calls = 0 |
| 1890 | ran_queries = [] |
| 1891 | |
| 1892 | config = { |
| 1893 | 'main': { |
| 1894 | 'use_keyring': 'False', |
| 1895 | }, |
| 1896 | 'connection': {}, |
| 1897 | } |
| 1898 | |
| 1899 | def __init__(self, **_args): |
| 1900 | self.logger = Logger() |
| 1901 | self.destructive_warning = False |
| 1902 | self.main_formatter = Formatter() |
| 1903 | self.redirect_formatter = Formatter() |
| 1904 | self.ssl_mode = 'auto' |
| 1905 | self.default_keepalive_ticks = 0 |
| 1906 | self.config_without_package_defaults = {'connection': {}} |
| 1907 | |
| 1908 | def connect(self, **_args): |
| 1909 | MockMyCli.connect_calls += 1 |
| 1910 | |
| 1911 | def run_query(self, query, checkpoint=None, new_line=True): |
| 1912 | MockMyCli.ran_queries.append(query) |
| 1913 | |
| 1914 | def run_cli(self): |
| 1915 | raise AssertionError('should not enter interactive cli') |
| 1916 | |
| 1917 | def close(self): |
| 1918 | pass |
| 1919 | |
| 1920 | import mycli.main |
| 1921 | |
| 1922 | monkeypatch.setattr(mycli.main, 'MyCli', MockMyCli) |
| 1923 | return mycli.main, mycli.main_modes.batch, MockMyCli |
| 1924 | |
| 1925 | |
| 1926 | def test_execute_arg_warns_about_ignoring_stdin(monkeypatch): |
no outgoing calls
no test coverage detected