def test_remove_extinfo(monkeypatch, setup_mdb_dir, caplog):
    tmpdir = setup_mdb_dir
    os.chdir(tmpdir)
    mdb_file = os.path.join(TESTS_DIR, 'all_test_files', 'manga_db.sqlite.sql')
    memdb = load_db_from_sql_file(mdb_file, ':memory:', True)
    monkeypatch.setattr('manga_db.manga_db.MangaDB._load_or_create_sql_db', (lambda x, y, z: (memdb, None)))
    mdb = MangaDB(tmpdir, mdb_file)
    b = mdb.get_book(16)
    caplog.clear()
    assert (b.remove_ext_info(99) is None)
    assert (caplog.record_tuples == [('manga_db.manga', logging.ERROR, 'No external info with id 99 found!')])
    assert (b.remove_ext_info(18) == 'https://www.tsumino.com/entry/43454')
    assert (len(b.ext_infos) == 1)
    assert (b.ext_infos[0].id == 16)
    assert b.remove_ext_info(16)
    assert (not b.ext_infos)
    caplog.clear()
    assert (b.remove_ext_info(4939) is None)
    assert (caplog.record_tuples == [('manga_db.manga', logging.WARNING, 'No external infos on book with id 16 or not fetched from DB yet!')])
def test_remove_extinfo(monkeypatch, setup_mdb_dir, caplog):
    tmpdir = setup_mdb_dir
    os.chdir(tmpdir)
    mdb_file = os.path.join(TESTS_DIR, 'all_test_files', 'manga_db.sqlite.sql')
    memdb = load_db_from_sql_file(mdb_file, ':memory:', True)
    monkeypatch.setattr('manga_db.manga_db.MangaDB._load_or_create_sql_db', (lambda x, y, z: (memdb, None)))
    mdb = MangaDB(tmpdir, mdb_file)
    b = mdb.get_book(16)
    caplog.clear()
    assert (b.remove_ext_info(99) is None)
    assert (caplog.record_tuples == [('manga_db.manga', logging.ERROR, 'No external info with id 99 found!')])
    assert (b.remove_ext_info(18) == 'https://www.tsumino.com/entry/43454')
    assert (len(b.ext_infos) == 1)
    assert (b.ext_infos[0].id == 16)
    assert b.remove_ext_info(16)
    assert (not b.ext_infos)
    caplog.clear()
    assert (b.remove_ext_info(4939) is None)
    assert (caplog.record_tuples == [('manga_db.manga', logging.WARNING, 'No external infos on book with id 16 or not fetched from DB yet!')])