Skip to content

Commit da29758

Browse files
Test requirements txt interface
1 parent 43fa37c commit da29758

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

tests/usethis/_interface/test_ci.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from pathlib import Path
2+
3+
from typer.testing import CliRunner
4+
5+
from usethis._interface.ci import app
6+
from usethis._test import change_cwd
7+
8+
9+
class TestBitbucket:
10+
def test_add(self, tmp_path: Path):
11+
# Act
12+
runner = CliRunner()
13+
with change_cwd(tmp_path):
14+
result = runner.invoke(
15+
app, # The CI menu only has 1 command (bitbucket
16+
# pipelines) so we skip the subcommand here
17+
)
18+
19+
# Assert
20+
assert result.exit_code == 0, result.output
21+
assert (tmp_path / "bitbucket-pipelines.yml").exists()
22+
23+
def test_remove(self, tmp_path: Path):
24+
# Arrange
25+
(tmp_path / "bitbucket-pipelines.yml").write_text("")
26+
27+
# Act
28+
runner = CliRunner()
29+
with change_cwd(tmp_path):
30+
result = runner.invoke(
31+
app, ["--remove"]
32+
) # The CI menu only has 1 command (bitbucket
33+
# pipelines) so we skip the subcommand here
34+
35+
# Assert
36+
assert result.exit_code == 0, result.output
37+
assert not (tmp_path / "bitbucket-pipelines.yml").exists()

tests/usethis/_interface/test_tool.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,17 @@ def test_cli_fail(self, uv_init_repo_dir: Path):
6060
pytest.fail("Expected subprocess.CalledProcessError")
6161

6262

63+
class TestRequirementsTxt:
64+
def test_runs(self, tmp_path: Path):
65+
# Act
66+
runner = CliRunner()
67+
with change_cwd(tmp_path):
68+
result = runner.invoke(app, ["requirements.txt"])
69+
70+
# Assert
71+
assert result.exit_code == 0, result.output
72+
73+
6374
class TestRuff:
6475
@pytest.mark.usefixtures("_vary_network_conn")
6576
def test_cli(self, uv_init_dir: Path):

0 commit comments

Comments
 (0)