Ejemplo n.º 1
0
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"
                          }})
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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"
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
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
Ejemplo n.º 6
0
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"
Ejemplo n.º 7
0
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()
Ejemplo n.º 8
0
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")
Ejemplo n.º 9
0
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
Ejemplo n.º 10
0
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
Ejemplo n.º 11
0
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
Ejemplo n.º 12
0
def test_best_match(token, service):
    client = Client(token, service, domain="states")
    entity = client.best_match({"name": "Misisipi"})
    assert entity.name == "Mississippi"
Ejemplo n.º 13
0
def test_best_match_an_alias(token, service):
    client = Client(token, service, domain="states")
    entity = client.best_match({"name": "Kalifornia"})
    assert entity.name == "California"
Ejemplo n.º 14
0
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