Exemplo n.º 1
0
 def test_new(self):
     path = pathlib.Path("path/to/package")
     summary = pp.PackageSummary(path)
     change = pp.PackagesPyfference(new={path: summary},
                                    changed=None,
                                    removed=None)
     assert change
     assert path in change.new
     assert str(change) == "New package ``path/to/package''"
Exemplo n.º 2
0
 def test_removed(self):
     path = pathlib.Path("path/to/package")
     summary = pp.PackageSummary(path)
     change = pp.PackagesPyfference(removed={path: summary},
                                    changed=None,
                                    new=None)
     assert change
     assert path in change.removed
     assert str(change) == "Removed package ``path/to/package''"
Exemplo n.º 3
0
 def test_changed(self):
     path = pathlib.Path("path/to/package")
     inner_change = MagicMock(spec=pp.PackagePyfference)
     inner_change.__str__.return_value = "Total rewrite"
     change = pp.PackagesPyfference(changed={path: inner_change},
                                    removed=None,
                                    new=None)
     assert change
     assert path in change.changed
     assert str(
         change) == "Package ``path/to/package'' changed:\n  Total rewrite"
Exemplo n.º 4
0
def _compare_packages_in_dir(
    old_dir: pathlib.Path,
    new_dir: pathlib.Path,
    old: FrozenSet[pathlib.Path],
    new: FrozenSet[pathlib.Path],
) -> Optional[pp.PackagesPyfference]:
    LOGGER.debug("Packages in the old directory: %s", str(old))
    LOGGER.debug("Packages in the new directory: %s", str(new))

    removed_packages = old - new
    both_packages = old.intersection(new)
    new_packages = new - old

    LOGGER.debug("Removed packages: %s", str(removed_packages))
    LOGGER.debug("Packages in both directories: %s", str(both_packages))
    LOGGER.debug("New packages: %s", str(new_packages))

    removed_package_summaries = {
        pkg: pp.summarize_package(old_dir / pkg)
        for pkg in removed_packages
    }
    changed_packages = {
        pkg: change
        for pkg, change in [(
            pkg,
            pp.pyff_package(pp.summarize_package(old_dir / pkg),
                            pp.summarize_package(new_dir / pkg)),
        ) for pkg in both_packages] if change is not None
    }
    new_package_summaries = {
        pkg: pp.summarize_package(new_dir / pkg)
        for pkg in new_packages
    }

    if removed_package_summaries or changed_packages or new_package_summaries:
        return pp.PackagesPyfference(removed_package_summaries,
                                     changed_packages, new_package_summaries)

    return None
Exemplo n.º 5
0
 def test_empty(self):
     assert not pp.PackagesPyfference(None, None, None)