From f5de27ccdd25e9c0b05932caf678c919a082f761 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sun, 28 May 2023 17:09:45 -0700 Subject: [PATCH] aider: Updated test_check_for_ctags_success to return valid JSON output for get_tags. # Context: USER: the output of the subprocess.run needs to be valid json like this: { "_type": "tag", "name": "status", "path": "aider/main.py", "pattern": "/^ status = main()$/", "kind": "variable" } ASSISTANT: To update the test `test_check_for_ctags_success` to return valid JSON output for `get_tags`, modify the `tests/test_repomap.py` file. Here's the change: ```python tests/test_repomap.py <<<<<<< ORIGINAL def test_check_for_ctags_success(self): with patch("subprocess.run") as mock_run: mock_run.return_value = CompletedProcess(args=["ctags", "--version"], returncode=0, stdout="Exuberant Ctags 5.8") ======= def test_check_for_ctags_success(self): with patch("subprocess.run") as mock_run: mock_run.return_value = CompletedProcess(args=["ctags", "--version"], returncode=0, stdout='''{ "_type": "tag", "name": "status", "path": "aider/main.py", "pattern": "/^ status = main()$/", "kind": "variable" }''') >>>>>>> UPDATED ``` This change updates the `stdout` value of the `CompletedProcess` object to return valid JSON output as specified. After making this change, run the tests again to ensure they pass. --- tests/test_repomap.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_repomap.py b/tests/test_repomap.py index 2599c2f0a..1f12bbbb7 100644 --- a/tests/test_repomap.py +++ b/tests/test_repomap.py @@ -65,7 +65,13 @@ def my_function(arg1, arg2): def test_check_for_ctags_success(self): with patch("subprocess.run") as mock_run: - mock_run.return_value = CompletedProcess(args=["ctags", "--version"], returncode=0, stdout="Exuberant Ctags 5.8") + mock_run.return_value = CompletedProcess(args=["ctags", "--version"], returncode=0, stdout='''{ + "_type": "tag", + "name": "status", + "path": "aider/main.py", + "pattern": "/^ status = main()$/", + "kind": "variable" +}''') repo_map = RepoMap(use_ctags=True) result = repo_map.check_for_ctags() self.assertTrue(result)