def validate_block_attrs_nested(token, service): client = Client(token, service) with pytest.raises(MalformedBlockAttributes): client.best_match({"name": "entity"}, block_attrs={"nested": { "too": "deep" }})
def test_entity_set_superseded_by(token, service): client = Client(token, service) entity = client.best_match({"name": "George W. Bush"}, domain="presidents") superseded = client.best_match( {"name": "George W. Bush"}, domain="politicians" ) superseded.set_superseded_by(entity) assert superseded.superseded_by == entity.uuid
def test_best_match_with_block_attrs(token, service): client = Client(token, service, domain="states") entity = client.best_match({"name": "Arkansas"}, block_attrs={"postal_code": "KS"}) assert entity.name == "Kansas" entity = client.best_match({"name": "Arkansas"}) assert entity.name == "Arkansas"
def test_entity_delete(token, service): client = Client(token, service, domain="presidents") entity = client.best_match({"name": "George W. Bush"}) entity.delete() assert entity.deleted is True entity = client.best_match( {"name": "George Bush, Jr."}, return_canonical=False ) entity.delete() assert entity.deleted is True entity = client.best_match( {"name": "George W. Bush"}, domain="politicians" ) entity.delete() assert entity.deleted is True
def test_entity_remove_alias_for(token, service): client = Client(token, service, domain="presidents") entity = client.best_match( {"name": "George Bush, Jr."}, return_canonical=False ) assert entity.name == "George Bush, Jr." entity.remove_alias_for() assert entity.alias_for is None
def test_update_entity_by_id(token, service): client = Client(token, service, domain="states") entity = client.best_match({"name": "Xanadu"}) entity = client.update_by_id(entity.uuid, { "sacred river": "Alph", "name": "Zanadu" }) assert entity.name == "Zanadu" entity = client.update_by_id(entity.uuid, {"name": "Xanadu"}) assert entity.sacred_river == "Alph" and entity.name == "Xanadu"
def test_empty_domain(token, service): client = Client(token, service) domain = client.create_domain("empty domain") entity = client.best_match({"name": "does not exist"}, domain=domain) assert entity is None entity = client.best_match_or_create({"name": "should create"}, domain=domain) assert entity.created is True assert entity.name == "should create" entity.delete() domain.delete()
def validate_block_attrs_not_a_dictionary(token, service): client = Client(token, service) with pytest.raises(MalformedBlockAttributes): client.best_match({"name": "entity"}, block_attrs="not a dictionary")
def test_entity_remove_superseded_by(token, service): client = Client(token, service, domain="politicians") entity = client.best_match({"name": "George W. Bush"}) entity.remove_superseded_by() assert entity.superseded_by is None
def test_entity_set_alias_for(token, service): client = Client(token, service, domain="presidents") entity = client.best_match({"name": "George W. Bush"}) alias = client.best_match({"name": "George Bush, Jr."}) alias.set_alias_for(entity) assert alias.alias_for == entity.uuid
def test_entity_update(token, service): client = Client(token, service, domain="presidents") entity = client.best_match({"name": "George W. Bush"}) entity.update({"number": 43}) assert entity.number == 43
def test_best_match(token, service): client = Client(token, service, domain="states") entity = client.best_match({"name": "Misisipi"}) assert entity.name == "Mississippi"
def test_best_match_an_alias(token, service): client = Client(token, service, domain="states") entity = client.best_match({"name": "Kalifornia"}) assert entity.name == "California"
def test_delete_entity_by_id(token, service): client = Client(token, service, domain="states") entity = client.best_match({"name": "Xanadu"}) response = client.delete_by_id(entity.uuid) assert response is True