Test that the generated .gitignore_file file on nextpy init contains the correct file names with correct formatting. Args: tmp_path: The root test path. mocker: The mock object. gitignore_exists: Whether a gitignore file exists in the root dir.
(tmp_path, mocker, gitignore_exists)
| 279 | |
| 280 | @pytest.mark.parametrize("gitignore_exists", [True, False]) |
| 281 | def test_initialize_non_existent_gitignore(tmp_path, mocker, gitignore_exists): |
| 282 | """Test that the generated .gitignore_file file on nextpy init contains the correct file |
| 283 | names with correct formatting. |
| 284 | |
| 285 | Args: |
| 286 | tmp_path: The root test path. |
| 287 | mocker: The mock object. |
| 288 | gitignore_exists: Whether a gitignore file exists in the root dir. |
| 289 | """ |
| 290 | expected = constants.GitIgnore.DEFAULTS.copy() |
| 291 | mocker.patch("nextpy.constants.GitIgnore.FILE", tmp_path / ".gitignore") |
| 292 | |
| 293 | gitignore_file = tmp_path / ".gitignore" |
| 294 | |
| 295 | if gitignore_exists: |
| 296 | gitignore_file.touch() |
| 297 | gitignore_file.write_text( |
| 298 | """*.db |
| 299 | __pycache__/ |
| 300 | """ |
| 301 | ) |
| 302 | |
| 303 | prerequisites.initialize_gitignore() |
| 304 | |
| 305 | assert gitignore_file.exists() |
| 306 | file_content = [ |
| 307 | line.strip() for line in gitignore_file.open().read().splitlines() if line |
| 308 | ] |
| 309 | assert set(file_content) - expected == set() |
| 310 | |
| 311 | |
| 312 | def test_app_default_name(tmp_path, mocker): |