(self)
| 23 | self.mock_webbrowser = self.webbrowser_patcher.start() |
| 24 | |
| 25 | def test_allowed_to_edit(self): |
| 26 | with GitTemporaryDirectory(): |
| 27 | repo = git.Repo() |
| 28 | |
| 29 | fname = Path("added.txt") |
| 30 | fname.touch() |
| 31 | repo.git.add(str(fname)) |
| 32 | |
| 33 | fname = Path("repo.txt") |
| 34 | fname.touch() |
| 35 | repo.git.add(str(fname)) |
| 36 | |
| 37 | repo.git.commit("-m", "init") |
| 38 | |
| 39 | # YES! |
| 40 | # Use a completely mocked IO object instead of a real one |
| 41 | io = MagicMock() |
| 42 | io.confirm_ask = MagicMock(return_value=True) |
| 43 | coder = Coder.create(self.GPT35, None, io, fnames=["added.txt"]) |
| 44 | |
| 45 | self.assertTrue(coder.allowed_to_edit("added.txt")) |
| 46 | self.assertTrue(coder.allowed_to_edit("repo.txt")) |
| 47 | self.assertTrue(coder.allowed_to_edit("new.txt")) |
| 48 | |
| 49 | self.assertIn("repo.txt", str(coder.abs_fnames)) |
| 50 | self.assertIn("new.txt", str(coder.abs_fnames)) |
| 51 | |
| 52 | self.assertFalse(coder.need_commit_before_edits) |
| 53 | |
| 54 | def test_allowed_to_edit_no(self): |
| 55 | with GitTemporaryDirectory(): |
nothing calls this directly
no test coverage detected