Esempio n. 1
0
def test_lookup_data_pool_add_invalid_lookup(test_data_cities):
    lookup = {"test": ["test", "test2"]}

    processor = LookupDataPool()

    with pytest.raises(TypeError):
        processor.add(lookup)
Esempio n. 2
0
def test_lookup_data_pool(test_data_cities):
    lookup = LookupData(name="cities", data=test_data_cities)

    processor = LookupDataPool()
    processor.add(lookup)

    assert processor.pool[lookup.name]
Esempio n. 3
0
def test_lookup_data_pool_duplicate_data_update_true(test_data_cities):
    lookup = LookupData(name="cities", data=test_data_cities)

    processor = LookupDataPool()
    processor.add(lookup=lookup, update=True)
    processor.add(lookup=lookup, update=True)

    assert processor.pool["cities"]
Esempio n. 4
0
def test_lookup_data_pool_duplicate_data(test_data_cities):
    lookup = LookupData(name="cities", data=test_data_cities)

    processor = LookupDataPool()
    processor.add(lookup)

    with pytest.raises(LookupDuplicateError):
        processor.add(lookup)
Esempio n. 5
0
def test_lookup_data_pool_remove_all_from_pool(test_data_cities):
    lookup = LookupData(name="cities", data=test_data_cities)

    processor = LookupDataPool()
    processor.add(lookup)

    processor.remove_all()

    assert not processor.pool
Esempio n. 6
0
def test_lookup_data_pool_remove_lookup_from_pool(test_data_cities):
    lookup = LookupData(name="cities", data=test_data_cities)

    processor = LookupDataPool()
    processor.add(lookup)

    processor.remove(lookup_to_remove="cities")

    with pytest.raises(KeyError):
        assert processor.pool["cities"]
Esempio n. 7
0
def test_lookup_data_pool_script_non_word_boundaries(test_data_cities):
    lookup = LookupData(name="cities", data=test_data_cities, script="latin")

    processor = LookupDataPool()
    processor.add(lookup)

    assert all([
        char in processor.pool["cities"].non_word_boundaries
        for char in SCRIPTS["latin"]["chars"]
    ])