def test_fetch_extinfo(monkeypatch, setup_mdb_dir):
    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 = Book(mdb, in_db=False, id=16)
    assert (b.ext_infos == [])
    db_con = memdb
    ei_rows_man = db_con.execute('SELECT * FROM ExternalInfo WHERE id IN (16, 18)').fetchall()
    ei1 = ExternalInfo(mdb, b, **ei_rows_man[0])
    ei2 = ExternalInfo(mdb, b, **ei_rows_man[1])
    assert (b._fetch_external_infos() == [ei1, ei2])
def test_fetch_extinfo(monkeypatch, setup_mdb_dir):
    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 = Book(mdb, in_db=False, id=16)
    assert (b.ext_infos == [])
    db_con = memdb
    ei_rows_man = db_con.execute('SELECT * FROM ExternalInfo WHERE id IN (16, 18)').fetchall()
    ei1 = ExternalInfo(mdb, b, **ei_rows_man[0])
    ei2 = ExternalInfo(mdb, b, **ei_rows_man[1])
    assert (b._fetch_external_infos() == [ei1, ei2])