def test_diff(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)
    b1_data = dict(id=None, title_eng='Same', title_foreign='Different1', language_id=1, pages=25, status_id=1, my_rating=4.3, category=['Manga'], collection=['Diff collection1'], groups=['Artistgroup'], artist=['Diff1', 'Diff2'], parody=['Blabla'], character=['Char1', 'Char2', 'Char3'], list=['to-read', 'to-download'], tag=['Tag1', 'Tag2', 'Tag3'], ext_infos=None, last_change=datetime.date(2018, 6, 3), note=None, favorite=0)
    b1 = Book(mdb, **b1_data)
    b2_data = dict(id=None, title_eng='Same', title_foreign='Different2', language_id=1, pages=27, status_id=1, my_rating=None, category=['Manga'], collection=['Diff collection2'], groups=['Artistgroup'], artist=['Diff', 'Diff2', 'Diff3'], parody=['Blabla'], character=['Char1', 'Char5', 'Char3'], list=['to-read', 'to-download'], tag=['Tag1', 'Tag2', 'Tag3'], ext_infos=None, last_change=datetime.date(2018, 4, 3), note=None, favorite=1)
    b2 = Book(mdb, **b2_data)
    (changes, change_str) = b1.diff(b2)
    changes_expected = dict(title_foreign='Different2', pages=27, my_rating=None, collection=({'Diff collection2'}, {'Diff collection1'}), artist=({'Diff', 'Diff3'}, {'Diff1'}), character=({'Char5'}, {'Char2'}), last_change=datetime.date(2018, 4, 3), favorite=1)
    assert (changes == changes_expected)
def test_diff(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)
    b1_data = dict(id=None, title_eng='Same', title_foreign='Different1', language_id=1, pages=25, status_id=1, my_rating=4.3, category=['Manga'], collection=['Diff collection1'], groups=['Artistgroup'], artist=['Diff1', 'Diff2'], parody=['Blabla'], character=['Char1', 'Char2', 'Char3'], list=['to-read', 'to-download'], tag=['Tag1', 'Tag2', 'Tag3'], ext_infos=None, last_change=datetime.date(2018, 6, 3), note=None, favorite=0)
    b1 = Book(mdb, **b1_data)
    b2_data = dict(id=None, title_eng='Same', title_foreign='Different2', language_id=1, pages=27, status_id=1, my_rating=None, category=['Manga'], collection=['Diff collection2'], groups=['Artistgroup'], artist=['Diff', 'Diff2', 'Diff3'], parody=['Blabla'], character=['Char1', 'Char5', 'Char3'], list=['to-read', 'to-download'], tag=['Tag1', 'Tag2', 'Tag3'], ext_infos=None, last_change=datetime.date(2018, 4, 3), note=None, favorite=1)
    b2 = Book(mdb, **b2_data)
    (changes, change_str) = b1.diff(b2)
    changes_expected = dict(title_foreign='Different2', pages=27, my_rating=None, collection=({'Diff collection2'}, {'Diff collection1'}), artist=({'Diff', 'Diff3'}, {'Diff1'}), character=({'Char5'}, {'Char2'}), last_change=datetime.date(2018, 4, 3), favorite=1)
    assert (changes == changes_expected)