fix: Fix annotation value comparison
This commit is contained in:
parent
3344147f1f
commit
d840609ecb
2 changed files with 12 additions and 2 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
import math
|
import math
|
||||||
from dataclasses import dataclass
|
|
||||||
from typing import Any, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
import chevron
|
import chevron
|
||||||
|
|
@ -21,7 +20,6 @@ COLORS: dict[str, tuple[float, float, float]] = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class Annotation:
|
class Annotation:
|
||||||
"""A PDF annotation object.
|
"""A PDF annotation object.
|
||||||
|
|
||||||
|
|
@ -140,3 +138,9 @@ class Annotation:
|
||||||
)
|
)
|
||||||
|
|
||||||
return cast("dict[str, str]", rawvalue)
|
return cast("dict[str, str]", rawvalue)
|
||||||
|
|
||||||
|
def __str__(self) -> str:
|
||||||
|
return f"Annotation({self.type}: '{self.file}', color: {self.color}, tag: '{self.tag}', page: {self.page}, content: '{self.content}', note: '{self.note}', minimum_similarity_color: {self.minimum_similarity_color})"
|
||||||
|
|
||||||
|
def __repr__(self) -> str:
|
||||||
|
return f"Annotation(type={self.type}, file='{self.file}', color={self.color}, tag='{self.tag}', page={self.page}, content='{self.content}', note='{self.note}', minimum_similarity_color={self.minimum_similarity_color})"
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,12 @@ from papis.document import Document
|
||||||
from papis_extract.annotation import Annotation
|
from papis_extract.annotation import Annotation
|
||||||
|
|
||||||
|
|
||||||
|
def test_value_comparison_works():
|
||||||
|
sut = Annotation("myfile", content="Here be content!", note="and a note")
|
||||||
|
other = Annotation("myfile", content="Here be different content!", note="but still a note")
|
||||||
|
assert sut != other
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"fmt_string,expected",
|
"fmt_string,expected",
|
||||||
[
|
[
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue