-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from Mic92/fix-hashes
- Loading branch information
Showing
12 changed files
with
131 additions
and
32 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import pytest | ||
import sys | ||
from pathlib import Path | ||
from typing import Type, Iterator, Any | ||
import shutil | ||
import tempfile | ||
from contextlib import contextmanager | ||
|
||
|
||
TEST_ROOT = Path(__file__).parent.resolve() | ||
sys.path.append(str(TEST_ROOT.parent)) | ||
|
||
|
||
class Helpers: | ||
@staticmethod | ||
def root() -> Path: | ||
return TEST_ROOT | ||
|
||
@staticmethod | ||
@contextmanager | ||
def testpkgs() -> Iterator[Path]: | ||
with tempfile.TemporaryDirectory() as tmpdirname: | ||
shutil.copytree( | ||
Helpers.root().joinpath("testpkgs"), tmpdirname, dirs_exist_ok=True | ||
) | ||
yield Path(tmpdirname) | ||
|
||
|
||
@pytest.fixture | ||
def helpers() -> Type[Helpers]: | ||
return Helpers |
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,16 +1,14 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from pathlib import Path | ||
from unittest import TestCase | ||
from nix_update.git import old_version_from_diff | ||
|
||
import conftest | ||
|
||
TEST_ROOT = Path(__file__).parent.resolve() | ||
|
||
|
||
class WordDiff(TestCase): | ||
def test_worddiff(self) -> None: | ||
with open(TEST_ROOT.joinpath("consul.patch")) as f: | ||
diff = f.read() | ||
def test_worddiff(helpers: conftest.Helpers) -> None: | ||
with open(helpers.root().joinpath("consul.patch")) as f: | ||
diff = f.read() | ||
s = old_version_from_diff(diff, 5, "1.9.0") | ||
self.assertEqual(s, "1.8.6") | ||
assert s == "1.8.6" |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from nix_update.options import Options | ||
from nix_update.update import update | ||
import subprocess | ||
import conftest | ||
|
||
|
||
def test_update(helpers: conftest.Helpers) -> None: | ||
with helpers.testpkgs() as path: | ||
opts = Options(attribute="pypi", import_path=path) | ||
update(opts) | ||
version = subprocess.run( | ||
[ | ||
"nix", | ||
"eval", | ||
"--raw", | ||
"--experimental-features", | ||
"nix-command", | ||
"-f", | ||
path, | ||
"pypi.version", | ||
], | ||
text=True, | ||
stdout=subprocess.PIPE, | ||
) | ||
assert version.stdout.strip() >= "3.0.1" |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ pkgs ? import <nixpkgs> {} }: | ||
{ | ||
pypi = pkgs.python3.pkgs.callPackage ./pypi.nix {}; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ buildPythonPackage, fetchPypi, twisted, mock, pytestCheckHook }: | ||
|
||
buildPythonPackage rec { | ||
pname = "python-mpd2"; | ||
version = "1.0.0"; | ||
src = fetchPypi { | ||
inherit pname version; | ||
sha256 = "0000000000000000000000000000000000000000000000000000"; | ||
}; | ||
checkInputs = [ | ||
pytestCheckHook | ||
twisted | ||
mock | ||
]; | ||
pytestFlagsArray = [ "mpd/tests.py" ]; | ||
} |