Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore empty lines, comments when reading in packages_by_dep_dag.txt file #7

Merged
merged 2 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions galaxy_release_util/point_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ def __repr__(self) -> str:
def get_sorted_package_paths(galaxy_root: pathlib.Path) -> List[pathlib.Path]:
root_package_path = galaxy_root.joinpath("packages")
sorted_packages = root_package_path.joinpath("packages_by_dep_dag.txt").read_text().splitlines()
# Check that all packages are listed in packages_by_dep_dag.txt ?
return [root_package_path.joinpath(package) for package in sorted_packages]
# Ignore empty lines and lines beginning with "#"
return [root_package_path.joinpath(p) for p in sorted_packages if p and not p.startswith("#")]


def read_package(package_path: pathlib.Path) -> Package:
Expand Down
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
pythonpath = .
51 changes: 43 additions & 8 deletions tests/test_release.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,51 @@
import pathlib

import pytest

from galaxy_release_util.point_release import (
get_next_devN_version,
get_root_version,
get_sorted_package_paths,
)

VERSION_PY_CONTENTS = """VERSION_MAJOR = "23.0"
VERSION_MINOR = "2"
VERSION = VERSION_MAJOR + (f".{VERSION_MINOR}" if VERSION_MINOR else "")
"""

PACKAGES_BY_DEP_DAG_CONTENTS = """
foo

bar
#this is a comment
baz
"""


@pytest.fixture(scope="session")
def make_version_file():
jdavcs marked this conversation as resolved.
Show resolved Hide resolved
def f(root):
file = root / "lib" / "galaxy" / "version.py"
file.parent.mkdir(parents=True)
file.write_text(VERSION_PY_CONTENTS)

return f

@pytest.fixture()
def galaxy_root(tmp_path: pathlib.Path):
version_py = tmp_path / "lib" / "galaxy" / "version.py"
version_py.parent.mkdir(parents=True)
version_py.write_text(VERSION_PY_CONTENTS)
return tmp_path

@pytest.fixture(scope="session")
def make_packages_file():
jdavcs marked this conversation as resolved.
Show resolved Hide resolved
def f(root):
file = root / "packages" / "packages_by_dep_dag.txt"
file.parent.mkdir(parents=True)
file.write_text(PACKAGES_BY_DEP_DAG_CONTENTS)

return f


@pytest.fixture(scope="session")
def galaxy_root(tmp_path_factory, make_version_file, make_packages_file):
jdavcs marked this conversation as resolved.
Show resolved Hide resolved
tmp_root = tmp_path_factory.mktemp("galaxy_root")
make_version_file(tmp_root)
make_packages_file(tmp_root)
return tmp_root


def test_get_root_version(galaxy_root):
Expand All @@ -35,3 +62,11 @@ def test_get_next_devN_version(galaxy_root):
assert version.minor == 0
assert version.micro == 3
assert version.dev == 0


def test_get_sorted_package_paths(galaxy_root):
packages = get_sorted_package_paths(galaxy_root)
assert len(packages) == 3
assert packages[0].name == "foo"
assert packages[1].name == "bar"
assert packages[2].name == "baz"
Loading