-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add flag to choose template This change allows providing a custom template arg flag -t/--template: ``` sinol-make init foo -t [repo link or disk path] [optional subdir] ``` It defaults to the upstream repository and example_package subdir. Changed the example_package id pattern from `abc` to `__ID__`. All filenames and file contents are now substituted. Changed the positional output directory argument to `-o/--output` flag to help avoid accidents. Added result directory cleanup on failure. * Test quick fix #1 * Always cleanup tmpdir * Add other git url schemes * One more used_tmpdir tweak * Pacify tests #2 * Leave old 'abc' template string for now * Test without connecting to github Try accessing the local git repo in the project root first when cloning example_package. Only if that doesn't work, fall back to online github. Also adds some extra local path tests to init/test_unit. Also removes one unnecessary os.getcwd() call. Also removes the old "abc" template string hack since we test the current template now. * Fall back on copying local directory instead of online github
- Loading branch information
Showing
9 changed files
with
106 additions
and
41 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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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 |
---|---|---|
@@ -1,9 +1,36 @@ | ||
import os | ||
import tempfile | ||
import pytest | ||
|
||
from sinol_make.commands.init import Command | ||
|
||
|
||
def test_if_download_successful(): | ||
def copy_template(rootdir): | ||
template_path = [rootdir, Command.DEFAULT_SUBDIR] | ||
command = Command() | ||
tmp_dir = command.download_template() | ||
assert os.path.isfile(os.path.join(tmp_dir,'config.yml')) | ||
with tempfile.TemporaryDirectory() as tmpdir: | ||
tmp_dir = command.download_template(tmpdir, template_path) | ||
assert os.path.isfile(os.path.join(tmp_dir, 'config.yml')) | ||
|
||
|
||
def test_clones_default_template(request): | ||
# try to avoid connecting to github when cloning example_package | ||
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 | ||
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): | ||
rootdir_absolute = str(request.config.rootdir) | ||
copy_template(rootdir_absolute) | ||
|
||
|
||
def test_copies_local_template_relative_path(request): | ||
os.chdir(os.path.join(request.config.rootdir, '..')) | ||
rootdir_relative = os.path.relpath(request.config.rootdir, os.getcwd()) | ||
copy_template(rootdir_relative) |