示例#1
0
def test_create_empty_config():
    config = retaggr.ReverseSearchConfig()
    assert config.__dict__ == {}
示例#2
0
def test_create_config_with_variable():
    config = retaggr.ReverseSearchConfig(app_name="py.test")
    assert config.__dict__ == {"app_name": "py.test"}
示例#3
0
def test_core_creation_with_no_iqdb():
    special_config = retaggr.ReverseSearchConfig(
        skip_iqdb=True, min_score=80.0)  # Minimal IQDB config
    core = retaggr.ReverseSearch(special_config)
    assert core.config == special_config
示例#4
0
async def test_core_search_image_not_all_api_keys():
    core = retaggr.ReverseSearch(retaggr.ReverseSearchConfig(
    ))  # Since we need a core without the config for this
    with pytest.raises(retaggr.MissingAPIKeysException):
        await core.search_image("danbooru", "irrelevant")
示例#5
0
import logging

logging.basicConfig(level=logging.DEBUG)

# Grab the relevant keys from the environment
danbooru_username = os.environ.get('DANBOORU_USERNAME', None)
danbooru_api_key = os.environ.get('DANBOORU_API_KEY', None)
e621_username = os.environ.get('E621_USERNAME', None)
app_name = os.environ.get('APP_NAME', None)
version = os.environ.get('APP_VERSION', None)
if not all(
    [danbooru_username, danbooru_api_key, e621_username, app_name, version]):
    raise ValueError("Missing Environment variables")
config = retaggr.ReverseSearchConfig(danbooru_username=danbooru_username,
                                     danbooru_api_key=danbooru_api_key,
                                     e621_username=e621_username,
                                     app_name=app_name,
                                     version=version,
                                     min_score=80.0)


def test_core_creation():
    core = retaggr.ReverseSearch(config)
    assert core.config == config


def test_core_creation_with_no_iqdb():
    special_config = retaggr.ReverseSearchConfig(
        skip_iqdb=True, min_score=80.0)  # Minimal IQDB config
    core = retaggr.ReverseSearch(special_config)
    assert core.config == special_config