Exemplo n.º 1
0
 def test_overwrite_git_abbreviation(self, mock_load_file: Mock) -> None:
     mock_load_file.return_value = {
         "git_abbreviations": {
             "gh": "https://---FAKE---.github.com/{0}"
         }
     }
     user_config = config.get_user_config()
     assert user_config.git_abbreviations == {
         "gh": "https://---FAKE---.github.com/{0}",
         "gl": "https://gitlab.com/{0}",
         "bb": "https://bitbucket.org/{0}",
     }
Exemplo n.º 2
0
 def test_unknown_config_key(self, mock_logger: Mock,
                             mock_load_file: Mock) -> None:
     mock_load_file.return_value = {"unknown_config": "fake-value"}
     assert config.get_user_config() == DEFAULT_CONFIG
     mock_logger.warning.assert_called_once()
Exemplo n.º 3
0
 def test_empty_config_file(self, mock_load_file: Mock) -> None:
     mock_load_file.return_value = {}
     assert config.get_user_config() == DEFAULT_CONFIG
Exemplo n.º 4
0
 def test_override_repo_cache(self, mock_load_file: Mock) -> None:
     mock_load_file.return_value = {"repo_cache": "fake/path/to/cache"}
     user_config = config.get_user_config()
     assert user_config.repo_cache == "fake/path/to/cache"
Exemplo n.º 5
0
from contextlib import contextmanager
from dataclasses import dataclass
from pathlib import Path
from typing import Any, Dict, Iterator, Optional
from unittest.mock import MagicMock, Mock, patch

import pytest

from qwikstart.config import get_user_config
from qwikstart.exceptions import RepoLoaderError
from qwikstart.repository import git

CACHE_DIR = get_user_config().repo_cache_path
TEST_URL = "https://github.com/user/repo"


class TestParseGitUrl:
    def test_https_url(self) -> None:
        git_url = self.parse_git_url("https://github.com/tonysyu/qwikstart")
        assert git_url.prefix == "https"
        assert git_url.separator == "://"
        assert git_url.path == "github.com/tonysyu/qwikstart"

    def test_git_ssh(self) -> None:
        git_url = self.parse_git_url("[email protected]:tonysyu/qwikstart.git")
        assert git_url.prefix == "git"
        assert git_url.separator == "@"
        assert git_url.path == "github.com/tonysyu/qwikstart.git"

    def parse_git_url(self, url: str) -> git.GitUrl:
        # Ensure that we get a non-None value to avoid mypy errors about non-checking.