about summary refs log tree commit diff stats
path: root/pkgs/by-name/up/update-vim-plugins/update_vim_plugins/tests
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-03-29 12:16:13 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-03-29 12:20:50 +0100
commitf5fde2475f81e1b714848c3c1ae4d5703738b65e (patch)
tree10d14fee0bdc09e6c4edaaa89c651b157c45092d /pkgs/by-name/up/update-vim-plugins/update_vim_plugins/tests
parentrefactor(pkgs/{yti,spodi,git-cleanup,nato,sort_song,virsh-del}): Remove (diff)
downloadnixos-config-f5fde2475f81e1b714848c3c1ae4d5703738b65e.zip
refactor(pkgs/update-vim-plugins): Remove
Let's start using the nixpkgs infrastructure instead of this python
application.
Diffstat (limited to 'pkgs/by-name/up/update-vim-plugins/update_vim_plugins/tests')
-rw-r--r--pkgs/by-name/up/update-vim-plugins/update_vim_plugins/tests/__init__.py0
-rw-r--r--pkgs/by-name/up/update-vim-plugins/update_vim_plugins/tests/fixtures.py44
-rw-r--r--pkgs/by-name/up/update-vim-plugins/update_vim_plugins/tests/test_nix.py32
-rw-r--r--pkgs/by-name/up/update-vim-plugins/update_vim_plugins/tests/test_plugin.py144
-rw-r--r--pkgs/by-name/up/update-vim-plugins/update_vim_plugins/tests/test_spec.py136
5 files changed, 0 insertions, 356 deletions
diff --git a/pkgs/by-name/up/update-vim-plugins/update_vim_plugins/tests/__init__.py b/pkgs/by-name/up/update-vim-plugins/update_vim_plugins/tests/__init__.py
deleted file mode 100644
index e69de29b..00000000
--- a/pkgs/by-name/up/update-vim-plugins/update_vim_plugins/tests/__init__.py
+++ /dev/null
diff --git a/pkgs/by-name/up/update-vim-plugins/update_vim_plugins/tests/fixtures.py b/pkgs/by-name/up/update-vim-plugins/update_vim_plugins/tests/fixtures.py
deleted file mode 100644
index 75dd251a..00000000
--- a/pkgs/by-name/up/update-vim-plugins/update_vim_plugins/tests/fixtures.py
+++ /dev/null
@@ -1,44 +0,0 @@
-import json
-
-import pytest
-from pytest_mock import MockerFixture
-
-from update_vim_plugins.nix import GitSource, UrlSource
-
-
-@pytest.fixture()
-def url():
-    return "https://example.com"
-
-
-@pytest.fixture()
-def rev():
-    return "1234567890abcdef"
-
-
-@pytest.fixture()
-def sha256():
-    return "sha256-1234567890abcdef"
-
-
-@pytest.fixture()
-def url_source(mocker: MockerFixture, url: str, sha256: str):
-    mocker.patch("subprocess.check_output", return_value=bytes(sha256, "utf-8"))
-    return UrlSource(url)
-
-
-@pytest.fixture()
-def git_source(mocker: MockerFixture, url: str, rev: str, sha256: str):
-    return_value = {
-        "url": url,
-        "rev": rev,
-        "date": "1970-01-01T00:00:00+00:00",
-        "path": "",
-        "sha256": sha256,
-        "fetchLFS": False,
-        "fetchSubmodules": False,
-        "deepClone": False,
-        "leaveDotGit": False,
-    }
-    mocker.patch("subprocess.check_output", return_value=json.dumps(return_value).encode("utf-8"))
-    return GitSource(url, rev)
diff --git a/pkgs/by-name/up/update-vim-plugins/update_vim_plugins/tests/test_nix.py b/pkgs/by-name/up/update-vim-plugins/update_vim_plugins/tests/test_nix.py
deleted file mode 100644
index 46e59f76..00000000
--- a/pkgs/by-name/up/update-vim-plugins/update_vim_plugins/tests/test_nix.py
+++ /dev/null
@@ -1,32 +0,0 @@
-from update_vim_plugins.nix import GitSource, License, UrlSource
-
-
-def test_url_source(url_source: UrlSource, url: str, sha256: str):
-    assert url_source.url == url
-    assert url_source.sha256 == sha256
-
-
-def test_url_source_nix_expression(url_source: UrlSource, url: str, sha256: str):
-    assert url_source.get_nix_expression() == f'fetchurl {{ url = "{url}"; sha256 = "{sha256}"; }}'
-
-
-def test_git_source(git_source: GitSource, url: str, rev: str, sha256: str):
-    assert git_source.url == url
-    assert git_source.sha256 == sha256
-    assert git_source.rev == rev
-
-
-def test_git_source_nix_expression(git_source: GitSource, url: str, rev: str, sha256: str):
-    assert git_source.get_nix_expression() == f'fetchgit {{ url = "{url}"; rev = "{rev}"; sha256 = "{sha256}"; }}'
-
-
-def test_license_github():
-    github_license = "MIT"
-    license = License.from_spdx_id(github_license)
-    assert license == License.MIT
-
-
-def test_license_gitlab():
-    gitlab_license = "mit"
-    license = License.from_spdx_id(gitlab_license)
-    assert license == License.MIT
diff --git a/pkgs/by-name/up/update-vim-plugins/update_vim_plugins/tests/test_plugin.py b/pkgs/by-name/up/update-vim-plugins/update_vim_plugins/tests/test_plugin.py
deleted file mode 100644
index 32377e24..00000000
--- a/pkgs/by-name/up/update-vim-plugins/update_vim_plugins/tests/test_plugin.py
+++ /dev/null
@@ -1,144 +0,0 @@
-import json
-from typing import Callable
-
-import pytest
-from pytest_mock import MockFixture
-
-from update_vim_plugins.nix import License, UrlSource
-from update_vim_plugins.plugin import GitHubPlugin, VimPlugin
-from update_vim_plugins.spec import PluginSpec
-
-
-@pytest.fixture()
-def mock_source(sha256: str):
-    class MockSource:
-        def __init__(self, *args, **kwargs):
-            pass
-
-        def get_nix_expression(self):
-            return "src"
-
-    return MockSource()
-
-
-@pytest.fixture()
-def mock_plugin(mock_source):
-    class MockVimPlugin(VimPlugin):
-        def __init__(self):
-            self.name = "test"
-            self.version = "1.0.0"
-            self.source = mock_source
-            self.description = "No description"
-            self.homepage = "https://example.com"
-            self.license = License.UNKNOWN
-
-    return MockVimPlugin()
-
-
-def test_vim_plugin_nix_expression(mock_plugin):
-    assert (
-        mock_plugin.get_nix_expression()
-        == 'test = buildVimPluginFrom2Nix { pname = "test"; version = "1.0.0"; src = src; meta = with lib; { description = "No description"; homepage = "https://example.com"; license = with licenses; [  ]; }; };'
-    )
-
-
-class MockResponse:
-    def __init__(self, status_code: int, content: bytes):
-        self.status_code = status_code
-        self.content = content
-
-    def json(self):
-        return json.loads(self.content)
-
-
-def mock_request_get(repsonses: dict[str, MockResponse]):
-    respones_not_found = MockResponse(404, b'{"message": "Not Found"}')
-
-    def mock_get(url: str, *args, **kwargs):
-        return repsonses.get(url, respones_not_found)
-
-    return mock_get
-
-
-@pytest.fixture()
-def github_commits_response():
-    return MockResponse(
-        200,
-        json.dumps(
-            {
-                "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
-                "commit": {
-                    "committer": {
-                        "date": "2011-04-14T16:00:49Z",
-                    },
-                },
-            }
-        ),
-    )
-
-
-@pytest.fixture()
-def github_get(github_commits_response: MockResponse):
-    repos_response = MockResponse(
-        200,
-        json.dumps(
-            {
-                "html_url": "https://github.com/octocat/Hello-World",
-                "description": "This your first repo!",
-                "fork": False,
-                "default_branch": "master",
-                "license": {
-                    "spdx_id": "MIT",
-                },
-            }
-        ),
-    )
-    responses = {
-        "https://api.github.com/repos/octocat/Hello-World": repos_response,
-        "https://api.github.com/repos/octocat/Hello-World/commits/master": github_commits_response,
-    }
-    return mock_request_get(responses)
-
-
-@pytest.fixture()
-def github_get_no_license(github_commits_response: MockResponse):
-    repos_response = MockResponse(
-        200,
-        json.dumps(
-            {
-                "html_url": "https://github.com/octocat/Hello-World",
-                "description": "This your first repo!",
-                "fork": False,
-                "default_branch": "master",
-            }
-        ),
-    )
-    responses = {
-        "https://api.github.com/repos/octocat/Hello-World": repos_response,
-        "https://api.github.com/repos/octocat/Hello-World/commits/master": github_commits_response,
-    }
-    return mock_request_get(responses)
-
-
-def test_github_plugin(mocker: MockFixture, github_get: Callable, url_source: UrlSource):
-    mocker.patch("requests.get", github_get)
-    url_source = mocker.patch("update_vim_plugins.nix.UrlSource", url_source)
-
-    spec = PluginSpec.from_spec("octocat/Hello-World")
-    plugin = GitHubPlugin(spec)
-
-    assert plugin.name == "Hello-World"
-    assert plugin.version == "2011-04-14"
-    assert plugin.description == "This your first repo!"
-    assert plugin.homepage == "https://github.com/octocat/Hello-World"
-    assert plugin.license == License.MIT
-
-
-def test_github_plugin_no_license(mocker: MockFixture, github_get_no_license: Callable, url_source: UrlSource):
-    mocker.patch("requests.get", github_get_no_license)
-    url_source = mocker.patch("update_vim_plugins.nix.UrlSource", url_source)
-
-    spec = PluginSpec.from_spec("octocat/Hello-World")
-    plugin = GitHubPlugin(spec)
-
-    assert plugin.license == License.UNKNOWN
diff --git a/pkgs/by-name/up/update-vim-plugins/update_vim_plugins/tests/test_spec.py b/pkgs/by-name/up/update-vim-plugins/update_vim_plugins/tests/test_spec.py
deleted file mode 100644
index 2b9a1d24..00000000
--- a/pkgs/by-name/up/update-vim-plugins/update_vim_plugins/tests/test_spec.py
+++ /dev/null
@@ -1,136 +0,0 @@
-import pytest
-
-from update_vim_plugins.spec import PluginSpec, RepositoryHost
-
-
-@pytest.fixture()
-def owner():
-    return "owner"
-
-
-@pytest.fixture()
-def repo():
-    return "repo.nvim"
-
-
-@pytest.fixture()
-def branch():
-    return "main"
-
-
-@pytest.fixture()
-def name():
-    return "repo-nvim"
-
-
-@pytest.fixture()
-def license():
-    return "mit"
-
-
-def test_from_spec_simple(owner: str, repo: str):
-    vim_plugin = PluginSpec.from_spec(f"{owner}/{repo}")
-
-    assert vim_plugin.owner == owner
-    assert vim_plugin.repo == repo
-
-
-def test_from_spec_with_gitref(owner: str, repo: str, branch: str):
-    vim_plugin = PluginSpec.from_spec(f"{owner}/{repo}:{branch}")
-
-    assert vim_plugin.branch == branch
-
-
-def test_from_spec_with_name(owner: str, repo: str, name: str):
-    vim_plugin = PluginSpec.from_spec(f"{owner}/{repo}::{name}")
-
-    assert vim_plugin.name == name
-
-
-@pytest.mark.parametrize("host", RepositoryHost)
-def test_from_spec_with_repository_host(owner: str, repo: str, host: RepositoryHost):
-    vim_plugin = PluginSpec.from_spec(f"{host.value}:{owner}/{repo}")
-
-    assert vim_plugin.repository_host == host
-
-
-def test_from_spec_without_repository_host(owner: str, repo: str):
-    vim_plugin = PluginSpec.from_spec(f"{owner}/{repo}")
-
-    assert vim_plugin.repository_host == RepositoryHost.GITHUB
-
-
-def test_from_spec_complex(owner: str, repo: str, branch: str, name: str):
-    vim_plugin = PluginSpec.from_spec(f"gitlab:{owner}/{repo}:{branch}:{name}")
-
-    assert vim_plugin.repository_host == RepositoryHost.GITLAB
-    assert vim_plugin.owner == owner
-    assert vim_plugin.repo == repo
-    assert vim_plugin.branch == branch
-    assert vim_plugin.name == name
-
-
-def test_from_spec_invalid_spec():
-    with pytest.raises(ValueError):
-        PluginSpec.from_spec("invalid_spec")
-
-
-def test_to_spec_simple(owner: str, repo: str):
-    vim_plugin = PluginSpec(RepositoryHost.GITHUB, owner, repo)
-
-    assert vim_plugin.to_spec() == f"{owner}/{repo}"
-
-
-def test_to_spec_with_branch(owner: str, repo: str, branch: str):
-    vim_plugin = PluginSpec(RepositoryHost.GITHUB, owner, repo, branch=branch)
-    assert vim_plugin.to_spec() == f"{owner}/{repo}:{branch}"
-
-
-def test_to_spec_with_name(owner: str, repo: str, name: str):
-    vim_plugin = PluginSpec(RepositoryHost.GITHUB, owner, repo, name=name)
-
-    assert vim_plugin.to_spec() == f"{owner}/{repo}::{name}"
-
-
-@pytest.mark.parametrize("host", [RepositoryHost.GITLAB, RepositoryHost.SOURCEHUT])
-def test_to_spec_with_repository_host(host: RepositoryHost, owner: str, repo: str):
-    vim_plugin = PluginSpec(host, owner, repo)
-
-    assert vim_plugin.to_spec() == f"{host.value}:{owner}/{repo}"
-
-
-def test_to_spec_complex(owner: str, repo: str, branch: str, name: str, license: str):
-    vim_plugin = PluginSpec(RepositoryHost.GITLAB, owner, repo, branch=branch, name=name, license=license)
-
-    assert vim_plugin.to_spec() == f"gitlab:{owner}/{repo}:{branch}:{name}:{license}"
-
-
-def test_spec_equal(owner: str, repo: str):
-    vim_plugin = PluginSpec(RepositoryHost.GITHUB, owner, repo)
-    vim_plugin2 = PluginSpec(RepositoryHost.GITHUB, owner, repo)
-
-    assert vim_plugin == vim_plugin2
-
-
-def test_spec_not_equal_different_branch(owner: str, repo: str):
-    vim_plugin = PluginSpec(RepositoryHost.GITHUB, owner, repo)
-    vim_plugin2 = PluginSpec(RepositoryHost.GITHUB, owner, repo, branch="main")
-
-    assert vim_plugin != vim_plugin2
-
-
-def test_spec_not_equal_different_name(owner: str, repo: str):
-    vim_plugin = PluginSpec(RepositoryHost.GITHUB, owner, repo)
-    vim_plugin2 = PluginSpec(RepositoryHost.GITHUB, owner, repo, name="renamed")
-
-    assert vim_plugin != vim_plugin2
-
-
-def test_spec_equal_same_normalized_name(owner: str):
-    repo = "repo.nvim"
-    name = "repo-nvim"
-
-    vim_plugin = PluginSpec(RepositoryHost.GITHUB, owner, repo)
-    vim_plugin2 = PluginSpec(RepositoryHost.GITHUB, owner, repo, name=name)
-
-    assert vim_plugin == vim_plugin2