-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: adds trestle init to tmp_repo fixture
Reduces code duplication in the end to end tests and any test that has git and trestle checks Signed-off-by: Jennifer Power <[email protected]>
- Loading branch information
Showing
3 changed files
with
16 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,20 +50,28 @@ | |
T = TypeVar("T") | ||
YieldFixture = Generator[T, None, None] | ||
|
||
_TEST_CONTENTS = """ | ||
test file | ||
""" | ||
_TEST_FILENAME = "test.txt" | ||
_TEST_PREFIX = "trestlebot_tests" | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def tmp_repo() -> YieldFixture[Tuple[str, Repo]]: | ||
"""Create a temporary git repository""" | ||
"""Create a temporary git repository with an initialized trestle workspace root""" | ||
with TemporaryDirectory(prefix=_TEST_PREFIX) as tmpdir: | ||
test_file = os.path.join(tmpdir, _TEST_FILENAME) | ||
with open(test_file, "x", encoding="utf8") as file: | ||
file.write(_TEST_CONTENTS) | ||
tmp_path = pathlib.Path(tmpdir) | ||
try: | ||
args = argparse.Namespace( | ||
verbose=0, | ||
trestle_root=tmp_path, | ||
full=True, | ||
local=False, | ||
govdocs=False, | ||
) | ||
init = InitCmd() | ||
init._run(args) | ||
except Exception as e: | ||
raise TrestleError( | ||
f"Initialization failed for temporary trestle directory: {e}." | ||
) | ||
repo = Repo.init(tmpdir) | ||
with repo.config_writer() as config: | ||
config.set_value("user", "email", "[email protected]") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters