Skip to content

Commit

Permalink
feat: new checksums functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dmyersturnbull committed Oct 6, 2021
1 parent 0515a73 commit 0b0387d
Show file tree
Hide file tree
Showing 8 changed files with 254 additions and 56 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,20 @@
Adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) and
[Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [0.14.0] - 2021-09-23
## [0.14.3] - 2021-10-05

### Added

- Some new methods to `Checksums`
- `Checksums` functions can now accept strings

## [0.14.2] - 2021-10-05

### Fixed

- Two minor bugs

## [0.14.1] - 2021-09-23

### Changed

Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sphinx >=4.0,<5.0
sphinx >=4.2,<5.0
sphinx-rtd-theme >=1.0,<2.0
sphinx-autoapi >=1.8,<2.0
sphinx-copybutton >=0.3,<1.0
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ build-backend = "poetry.masonry.api"

[tool.poetry]
name = "typeddfs"
version = "0.14.2"
version = "0.14.3"
description = "Pandas DataFrame subclasses that enforce structure and can self-organize."
authors = ["Douglas Myers-Turnbull"]
maintainers = ["dmyersturnbull"]
Expand Down Expand Up @@ -112,7 +112,7 @@ pytest-cov = "^3"
flake8 = "^3.9"
flake8-docstrings = "^1.5"
flake8-bugbear = ">=21"
Sphinx = "^4.0"
Sphinx = "^4.2"
sphinx-copybutton = ">=0.4, <1.0"
sphinx-autoapi = "^1.5"
sphinx-rtd-theme = "^1"
Expand Down
31 changes: 29 additions & 2 deletions tests/test_checksums.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,39 @@
from pathlib import Path

import pytest

from typeddfs.checksums import Checksums
from typeddfs.checksums import ChecksumMappingOpt, Checksums
from typeddfs.df_errors import (
HashContradictsExistingError,
HashExistsError,
HashFilenameMissingError,
)


class TestBuilders:
def test(self):
def test_get_algorithm(self):
assert Checksums.get_algorithm("sha-256") == "sha256"

def test_update(self):
assert Checksums.get_updated_hashes({}, {}) == ChecksumMappingOpt({})
original = {Path("cat"): "0x5", "ok": "0x63"}
update = {"cat": None, "other": "wads"}
expected = {
Path("cat").resolve(): None,
Path("ok").resolve(): "0x63",
Path("other").resolve(): "wads",
}
assert Checksums.get_updated_hashes(original, update) == ChecksumMappingOpt(expected)
with pytest.raises(HashExistsError):
Checksums.get_updated_hashes({"x": "5"}, {"x": "5"}, overwrite=False)
assert Checksums.get_updated_hashes({"x": "5"}, {"x": "5"}, overwrite=None) == {
Path("x").resolve(): "5"
}
with pytest.raises(HashContradictsExistingError):
Checksums.get_updated_hashes({"x": "5"}, {"x": "4"}, overwrite=None)
with pytest.raises(HashFilenameMissingError):
Checksums.get_updated_hashes({}, {"x": "4"}, missing_ok=False)


if __name__ == "__main__":
pytest.main()
2 changes: 1 addition & 1 deletion tests/test_cli_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest
from pandas import Period

from typeddfs import TypedDfs, FileFormat
from typeddfs import FileFormat, TypedDfs
from typeddfs.cli_help import DfCliHelp


Expand Down
Loading

0 comments on commit 0b0387d

Please sign in to comment.