CoolFace
Apppublic

dgobran/case-study-1

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
test.py29 linesDownload Raw Back to root
1import unittest2from unittest.mock import patch3from inference import respond4 5class TestRespondFunction(unittest.TestCase):6    # GitHub Copilot generated this test case7    @patch('inference.pipe')8    def test_respond_with_local_model(self, mock_pipe):9        # Mock the pipe function10        mock_pipe.return_value = [{"generated_text": [{"content": "Inference cancelled."}]}]11 12        # Set stop_inference to True13        global stop_inference14        stop_inference = True15 16        # Call the respond function with use_local_model=True17        response = respond(18            message="Test input",19            use_local_model=True20        )21 22        # Assert that the pipe function was called23        mock_pipe.assert_called_once()24 25        # Assert the response is "Inference cancelled."26        self.assertEqual(response, "Inference cancelled.")27 28if __name__ == '__main__':29    unittest.main()