From c8b9518c582f814fb83a50bcd47faa461b121d91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bartmi=C5=84ski?= Date: Mon, 9 Dec 2024 23:21:47 +0100 Subject: [PATCH] Fall back on copying local directory instead of online github --- tests/commands/init/test_integration.py | 11 +++++++---- tests/commands/init/test_unit.py | 15 ++++++++------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/tests/commands/init/test_integration.py b/tests/commands/init/test_integration.py index d78d603b..b56fa015 100644 --- a/tests/commands/init/test_integration.py +++ b/tests/commands/init/test_integration.py @@ -15,12 +15,15 @@ def test_init_clones_default_template(capsys, request, temp_workdir): args = ["init", "xyz"] # try to avoid connecting to github when cloning example_package - git_dir = os.path.join(request.config.rootdir, '.git') + rootdir = str(request.config.rootdir) + git_dir = os.path.join(rootdir, '.git') if os.path.exists(git_dir): - git_local_url = os.path.join('file://', request.config.rootdir) + git_local_url = os.path.join('file://', rootdir) args.extend(["-t", git_local_url, "example_package"]) - # currently this does fallback on github if the local repo is not available - # if needed we could take a dependency on gitpython and mock up a repo + else: + # copy from root directory instead of cloning + # if needed we could take a dependency on gitpython and mock up a repo + args.extend(["-t", rootdir, "example_package"]) args = parser.parse_args(args) command = Command() diff --git a/tests/commands/init/test_unit.py b/tests/commands/init/test_unit.py index 2933e27c..a4128b6c 100644 --- a/tests/commands/init/test_unit.py +++ b/tests/commands/init/test_unit.py @@ -1,5 +1,6 @@ import os import tempfile +import pytest from sinol_make.commands.init import Command @@ -14,14 +15,14 @@ def copy_template(rootdir): def test_clones_default_template(request): # try to avoid connecting to github when cloning example_package - git_dir = os.path.join(request.config.rootdir, '.git') - if os.path.exists(git_dir): - git_local_url = os.path.join('file://', request.config.rootdir) - copy_template(git_local_url) - else: - # currently this does fallback on github if the local repo is not available + rootdir = str(request.config.rootdir) + git_dir = os.path.join(rootdir, '.git') + if not os.path.exists(git_dir): # if needed we could take a dependency on gitpython and mock up a repo - copy_template(Command.DEFAULT_TEMPLATE) + pytest.skip(f".git not found in rootdir {rootdir}") + + git_local_url = os.path.join('file://', rootdir) + copy_template(git_local_url) def test_copies_local_template_absolute_path(request):