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

Prepare first release #4

Merged
merged 3 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@

Bi-directional version.cfg <–> requirements.txt synchronization

This program can be used to synchronize a `versions.cfg` used by
[zc.buildout](https://pypi.org/project/zc.buildout/) with a `requirements.txt`
as used by [pip](https://pypi.org/project/pip/).

This is be helpful to keep using `zc.buildout` but get version updates via
GitHub's Dependabot.

-----

**Table of Contents**
Expand Down
2 changes: 1 addition & 1 deletion src/vereqsyn/__about__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-present Michael Howitz <[email protected]>
#
# SPDX-License-Identifier: MIT
__version__ = "0.0.1"
__version__ = "0.9"
2 changes: 1 addition & 1 deletion src/vereqsyn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def _cleanup(self):


@dataclass
class VersionCfgRequirementsTxtSync:
class VersionsCfgRequirementsTxtSync:
"""Keep a versions.cfg in sync with a requirements.txt file."""

requirements_txt: str | None = None
Expand Down
10 changes: 5 additions & 5 deletions src/vereqsyn/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
def main(argv=None):
parser = argparse.ArgumentParser(
"vereqsyn",
"{prog} <version.cfg> <requirements.txt>",
"Bi-directional version.cfg <-> requirements.txt synchronization",
"%(prog)s <versions.cfg> <requirements.txt>",
"Bi-directional versions.cfg <-> requirements.txt synchronization",
)
parser.add_argument("version_cfg", action="store")
parser.add_argument("requirements_txt", action="store")
parser.add_argument("versions_cfg", action="store", help="path to versions.cfg")
parser.add_argument("requirements_txt", action="store", help="path to requirements.txt")

args = parser.parse_args(argv)
command = vereqsyn.VersionCfgRequirementsTxtSync(args.requirements_txt, args.version_cfg)
command = vereqsyn.VersionsCfgRequirementsTxtSync(args.requirements_txt, args.versions_cfg)
command.update()


Expand Down
16 changes: 8 additions & 8 deletions tests/test_vereqsyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from vereqsyn import ConfigFile, VersionCfgRequirementsTxtSync
from vereqsyn import ConfigFile, VersionsCfgRequirementsTxtSync

from .testing import tmp_copy

Expand All @@ -11,15 +11,15 @@ def test_VersionCfg_RequirementsTxt_Sync___sync__1(fixtures, tmp_path):
"""It syncs newer versions in both directions."""
r3 = tmp_copy(tmp_path, fixtures / "r3.txt")
v3 = tmp_copy(tmp_path, fixtures / "v3.cfg")
component = VersionCfgRequirementsTxtSync(r3, v3)
component = VersionsCfgRequirementsTxtSync(r3, v3)
assert not component.in_sync()
component._sync() # noqa: SLF001 Private member accessed
assert component.in_sync()


def test_VersionCfg_RequirementsTxt_Sync___sync__2(fixtures):
"""It raises an exception if the package names are out of order."""
component = VersionCfgRequirementsTxtSync(fixtures / "r1.txt", fixtures / "v2.cfg")
component = VersionsCfgRequirementsTxtSync(fixtures / "r1.txt", fixtures / "v2.cfg")
with pytest.raises(ReferenceError) as err:
component._sync() # noqa: SLF001 Private member accessed
assert str(err.value).startswith("Package entries out of order: Faker != FactoryBoy. Please recreate")
Expand All @@ -29,15 +29,15 @@ def test_VersionCfg_RequirementsTxt_Sync___recreate__1(fixtures, tmp_path):
"""It recreates requirements.txt from versions.cfg."""
r1 = tmp_copy(tmp_path, fixtures / "r1.txt")
v2 = tmp_copy(tmp_path, fixtures / "v2.cfg")
component = VersionCfgRequirementsTxtSync(r1, v2)
component = VersionsCfgRequirementsTxtSync(r1, v2)
assert not component.in_sync()
component._recreate() # noqa: SLF001 Private member accessed
assert component.in_sync()


def test_VersionCfg_RequirementsTxt_Sync__in_sync__1(fixtures):
"""It returns `True` if config files are in sync."""
component = VersionCfgRequirementsTxtSync(requirements_txt=fixtures / "r1.txt", version_cfg=fixtures / "v1.cfg")
component = VersionsCfgRequirementsTxtSync(requirements_txt=fixtures / "r1.txt", version_cfg=fixtures / "v1.cfg")
assert component.in_sync()


Expand All @@ -52,15 +52,15 @@ def test_VersionCfg_RequirementsTxt_Sync__in_sync__1(fixtures):
)
def test_VersionCfg_RequirementsTxt_Sync__in_sync__2(fixtures, r_name, v_name):
"""It returns `False` if config files are out of sync."""
component = VersionCfgRequirementsTxtSync(requirements_txt=fixtures / r_name, version_cfg=fixtures / v_name)
component = VersionsCfgRequirementsTxtSync(requirements_txt=fixtures / r_name, version_cfg=fixtures / v_name)
assert not component.in_sync()


def test_VersionCfg_RequirementsTxt_Sync__update__1(fixtures, tmp_path):
"""It updates out of sync files."""
r3 = tmp_copy(tmp_path, fixtures / "r3.txt")
v3 = tmp_copy(tmp_path, fixtures / "v3.cfg")
component = VersionCfgRequirementsTxtSync(requirements_txt=r3, version_cfg=v3)
component = VersionsCfgRequirementsTxtSync(requirements_txt=r3, version_cfg=v3)
assert not component.in_sync()
component.update()
assert component.in_sync()
Expand All @@ -70,7 +70,7 @@ def test_VersionCfg_RequirementsTxt_Sync__update__2(fixtures, tmp_path):
"""It recreates requirements.txt if packages are out of order."""
r1 = tmp_copy(tmp_path, fixtures / "r1.txt")
v2 = tmp_copy(tmp_path, fixtures / "v2.cfg")
component = VersionCfgRequirementsTxtSync(requirements_txt=r1, version_cfg=v2)
component = VersionsCfgRequirementsTxtSync(requirements_txt=r1, version_cfg=v2)
assert not component.in_sync()
component.update()
assert component.in_sync()
Expand Down