1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
from pathlib import Path
import pytest
from briefcase.commands.create import cookiecutter_cache_path
@pytest.mark.parametrize(
"template, cache_dir",
[
# Git/Github URLs
("https://github.com/beeware/template.git", "template"),
("https://github.com/beeware/template/", "template"),
("https://github.com/beeware/template", "template"),
("gh:beeware/template", "template"),
("git+ssh://git@github.com/beeware/template.git", "template"),
("git+https://beeware.org/template", "template"),
# Paths are valid templates. They're not cached, but this
# method returns as if they would be, and the "is it a repo"
# check performed by git will fail instead.
("/path/to/template/", "template"),
("/path/to/template", "template"),
("path/to/template/", "template"),
("path/to/template", "template"),
("template/", "template"),
("template", "template"),
# Zipfiles are also valid templates. Same rules apply as with paths.
("https://example.com/path/to/template.zip", "template.zip"),
("/path/to/template.zip", "template.zip"),
("path/to/template.zip", "template.zip"),
],
)
def test_cookiecutter_cache_path(template, cache_dir):
"""The cookiecutter cache path can be determined for various template types."""
assert cookiecutter_cache_path(template) == (
Path.home() / ".cookiecutters" / cache_dir
)
|