nix-update/tests/test_branch.py

30 lines
807 B
Python
Raw Normal View History

2022-01-19 04:11:05 +03:00
#!/usr/bin/env python3
import unittest.mock
from pathlib import Path
from typing import BinaryIO
2022-11-24 20:33:58 +03:00
from urllib.parse import urlparse
2022-01-19 04:11:05 +03:00
2022-11-21 23:37:14 +03:00
import conftest
2022-01-19 04:11:05 +03:00
from nix_update.version import fetch_latest_version
from nix_update.version.version import VersionPreference
TEST_ROOT = Path(__file__).parent.resolve()
def fake_urlopen(url: str) -> BinaryIO:
return open(TEST_ROOT.joinpath("test_branch.atom"), "rb")
def test_branch(helpers: conftest.Helpers) -> None:
with unittest.mock.patch("urllib.request.urlopen", fake_urlopen):
assert (
fetch_latest_version(
2022-11-24 20:33:58 +03:00
urlparse("https://github.com/Mic92/nix-update"),
2022-01-19 04:11:05 +03:00
VersionPreference.BRANCH,
"(.*)",
"master",
).number
== "unstable-2021-12-13"
)