From 6714b584a502ec94f301d71ff04a1fbb33fc41ad Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Sun, 31 Dec 2023 16:05:02 -0700 Subject: [PATCH] add test for telemetry/sys_info --- tests/telemetry/test_sys_info.py | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/telemetry/test_sys_info.py diff --git a/tests/telemetry/test_sys_info.py b/tests/telemetry/test_sys_info.py new file mode 100644 index 00000000..c6892b5d --- /dev/null +++ b/tests/telemetry/test_sys_info.py @@ -0,0 +1,33 @@ +iimport pytest +from unittest.mock import Mock +from your_module import interpreter_info, system_info # replace with your actual module name + +def test_interpreter_info(mocker): + mocker.patch('subprocess.check_output', return_value='curl output') + interpreter = Mock() + interpreter.offline = True + interpreter.llm.api_base = 'http://api_base' + interpreter.llm.supports_vision = True + interpreter.llm.model = 'model' + interpreter.llm.supports_functions = True + interpreter.llm.context_window = 'context_window' + interpreter.llm.max_tokens = 100 + interpreter.auto_run = True + interpreter.llm.api_base = 'http://api_base' + interpreter.offline = True + interpreter.system_message = 'system_message' + interpreter.messages = [{'content': 'message_content'}] + result = interpreter_info(interpreter) + assert 'curl output' in result + +def test_system_info(mocker): + mocker.patch('your_module.get_oi_version', return_value=('cmd_version', 'pkg_version')) # replace with your actual module name + mocker.patch('your_module.get_python_version', return_value='python_version') # replace with your actual module name + mocker.patch('your_module.get_pip_version', return_value='pip_version') # replace with your actual module name + mocker.patch('your_module.get_os_version', return_value='os_version') # replace with your actual module name + mocker.patch('your_module.get_cpu_info', return_value='cpu_info') # replace with your actual module name + mocker.patch('your_module.get_ram_info', return_value='ram_info') # replace with your actual module name + mocker.patch('your_module.interpreter_info', return_value='interpreter_info') # replace with your actual module name + interpreter = Mock() + result = system_info(interpreter) + assert 'interpreter_info' in result \ No newline at end of file