Beispiel #1
0
def test_searches_configs_config_allowed_kwargs_and_kwargs():
    from snovault.elasticsearch.searches.configs import Config
    c = Config(allowed_kwargs=['first_thing'],
               other_thing='abc',
               something_else=True)
    assert c._allowed_kwargs == ['first_thing']
    assert c._kwargs == {'other_thing': 'abc', 'something_else': True}
Beispiel #2
0
def test_searches_configs_config_getitem():
    from snovault.elasticsearch.searches.configs import Config
    c = Config(allowed_kwargs=['first_thing', 'other_thing'],
               other_thing='abc',
               something_else=True)
    assert c['other_thing'] == 'abc'
    with pytest.raises(KeyError):
        c['nothing']
Beispiel #3
0
def test_searches_configs_config_len():
    from snovault.elasticsearch.searches.configs import Config
    c = Config(allowed_kwargs=['first_thing', 'other_thing'],
               other_thing='abc',
               something_else=True)
    assert len(c) == 1
Beispiel #4
0
def test_searches_configs_config_iter():
    from snovault.elasticsearch.searches.configs import Config
    c = Config(allowed_kwargs=['first_thing', 'other_thing'],
               other_thing='abc',
               something_else=True)
    assert {k: v for k, v in c.items()} == {'other_thing': 'abc'}
Beispiel #5
0
def test_searches_configs_config_filtered_kwargs():
    from snovault.elasticsearch.searches.configs import Config
    c = Config()
    assert c._filtered_kwargs() == {}
    c = Config(allowed_kwargs=['first_thing'],
               other_thing='abc',
               something_else=True)
    assert c._filtered_kwargs() == {}
    c = Config(allowed_kwargs=['first_thing', 'other_thing'],
               other_thing='abc',
               something_else=True)
    assert c._filtered_kwargs() == {'other_thing': 'abc'}
    c = Config(allowed_kwargs=['first_thing', 'other_thing'],
               other_thing=None,
               something_else=True)
    assert c._filtered_kwargs() == {}
Beispiel #6
0
def test_searches_configs_config_init():
    from snovault.elasticsearch.searches.configs import Config
    c = Config()
    assert isinstance(c, Config)
Beispiel #7
0
def test_searches_configs_config_kwargs():
    from snovault.elasticsearch.searches.configs import Config
    c = Config()
    assert c._kwargs == {}
    c = Config(other_thing='abc', something_else=True)
    assert c._kwargs == {'other_thing': 'abc', 'something_else': True}
Beispiel #8
0
def test_searches_configs_config_allowed_kwargs():
    from snovault.elasticsearch.searches.configs import Config
    c = Config()
    assert c._allowed_kwargs == []
    c = Config(allowed_kwargs=['size'])
    assert c._allowed_kwargs == ['size']