Skip to content
Snippets Groups Projects
Commit bf279343 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

sty

parent 9c6a2dff
Branches
Tags
2 merge requests!91Release 0.3,!67MAINT: introduce an identifiable class
Pipeline #30453 passed with warnings
...@@ -33,31 +33,32 @@ from caoscrawler.identifiable import Identifiable ...@@ -33,31 +33,32 @@ from caoscrawler.identifiable import Identifiable
from caoscrawler.identified_cache import _create_hashable_string as create_hash_string from caoscrawler.identified_cache import _create_hashable_string as create_hash_string
import pytest
def test_create_hash(): def test_create_hash():
assert _create_hashable_string( assert _create_hashable_string(
Identifiable(name="A", record_type="B")) == "P<B>N<A>Path<None>" Identifiable(name="A", record_type="B")) == "P<B>N<A>Path<None>"
assert _create_hashable_string( assert _create_hashable_string(
Identifiable(name="A", record_type="B", properties={'a': 5})) == "P<B>N<A>Path<None>a:5" Identifiable(name="A", record_type="B", properties={'a': 5})) == "P<B>N<A>Path<None>a:5"
assert (_create_hashable_string( a = _create_hashable_string(
Identifiable(name="A", record_type="B", properties={'a': 4, 'b': 5} Identifiable(name="A", record_type="B", properties={'a': 4, 'b': 5}))
)) == _create_hashable_string( b = _create_hashable_string(
Identifiable(name="A", record_type="B", properties={'b': 5, 'a': 4}))) Identifiable(name="A", record_type="B", properties={'b': 5, 'a': 4}))
assert a == b
assert (_create_hashable_string(Identifiable(name="A", record_type="B", assert (_create_hashable_string(Identifiable(name="A", record_type="B",
properties={'a': db.Record(id=12)})) == "P<B>N<A>Path<None>a:12") properties={'a': db.Record(id=12)})) == "P<B>N<A>Path<None>a:12")
assert (_create_hashable_string( a = _create_hashable_string(
Identifiable(name="A", record_type="B", properties={'a': [db.Record(id=12)]}) Identifiable(name="A", record_type="B", properties={'a': [db.Record(id=12)]}))
) == "P<B>N<A>Path<None>a:[12]") assert (a == "P<B>N<A>Path<None>a:[12]")
assert (_create_hashable_string(Identifiable(name="A", record_type="B", properties={'a': [12]}) assert (_create_hashable_string(Identifiable(name="A", record_type="B", properties={'a': [12]})
) == "P<B>N<A>Path<None>a:[12]") ) == "P<B>N<A>Path<None>a:[12]")
assert (_create_hashable_string( assert (
Identifiable(name="A", record_type="B", properties={'a': [db.Record(id=12), 11]}) _create_hashable_string(
) == "P<B>N<A>Path<None>a:[12, 11]") Identifiable(name="A", record_type="B", properties={'a': [db.Record(id=12), 11]})
assert (_create_hashable_string( ) == "P<B>N<A>Path<None>a:[12, 11]")
Identifiable(record_type="B", properties={'a': [db.Record()]})) assert (
!= _create_hashable_string( _create_hashable_string(
Identifiable(record_type="B", properties={'a': [db.Record()]})
) != _create_hashable_string(
Identifiable(record_type="B", properties={'a': [db.Record()]}))) Identifiable(record_type="B", properties={'a': [db.Record()]})))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment