Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

newer dataclasses-json breaks the testsuite #439

Open
baldurmen opened this issue Sep 6, 2023 · 1 comment
Open

newer dataclasses-json breaks the testsuite #439

baldurmen opened this issue Sep 6, 2023 · 1 comment

Comments

@baldurmen
Copy link

Hello again on a new platform! Happy to see this program is still maintained :D

Trying to update the Debian package to 0.12.0, I've ran into this testsuite failure:

___________________________ test_get_music_directory ___________________________

cache_adapter = <sublime_music.adapters.filesystem.adapter.FilesystemAdapter object at 0x7f16d7808e50>

    def test_get_music_directory(cache_adapter: FilesystemAdapter):
        dir_id = "d1"
        with pytest.raises(CacheMissError):
            cache_adapter.get_directory(dir_id)
    
        # Simulate the directory details being retrieved from Subsonic.
        cache_adapter.ingest_new_data(
            KEYS.DIRECTORY,
            dir_id,
            SubsonicAPI.Directory(
                dir_id,
                title="foo",
                parent_id=None,
>               _children=[json.loads(s.to_json()) for s in MOCK_SUBSONIC_SONGS[:2]]
                + [
                    {
                        "id": "542",
                        "parent": dir_id,
                        "isDir": True,
                        "title": "Crash My Party",
                    }
                ],
            ),
        )

tests/adapter_tests/filesystem_adapter_tests.py:958: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/adapter_tests/filesystem_adapter_tests.py:958: in <listcomp>
    _children=[json.loads(s.to_json()) for s in MOCK_SUBSONIC_SONGS[:2]]
/usr/lib/python3/dist-packages/dataclasses_json/api.py:37: in to_json
    return json.dumps(self.to_dict(encode_json=False),
/usr/lib/python3/dist-packages/dataclasses_json/api.py:73: in to_dict
    return _asdict(self, encode_json=encode_json)
/usr/lib/python3/dist-packages/dataclasses_json/core.py:377: in _asdict
    value = _asdict(
/usr/lib/python3/dist-packages/dataclasses_json/core.py:385: in _asdict
    return _encode_overrides(dict(result), _user_overrides_or_exts(obj),
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

kvs = {'_artist': None, '_genre': None, 'artist': None, 'artist_id': None, ...}
overrides = {'_artist': FieldOverride(encoder=None, decoder=None, mm_field=None, letter_case=<function config.<locals>.override at...ride(encoder=None, decoder=None, mm_field=None, letter_case=<function camelcase at 0x7f16d82ad800>, exclude=None), ...}
encode_json = False

    def _encode_overrides(kvs, overrides, encode_json=False):
        override_kvs = {}
        for k, v in kvs.items():
            if k in overrides:
                exclude = overrides[k].exclude
                # If the exclude predicate returns true, the key should be
                #  excluded from encoding, so skip the rest of the loop
                if exclude and exclude(v):
                    continue
                letter_case = overrides[k].letter_case
                original_key = k
                k = letter_case(k) if letter_case is not None else k
                if k in override_kvs:
>                   raise ValueError(
                        f"Multiple fields map to the same JSON "
                        f"key after letter case encoding: {k}"
                    )
E                   ValueError: Multiple fields map to the same JSON key after letter case encoding: artist

/usr/lib/python3/dist-packages/dataclasses_json/core.py:116: ValueError
------------------------------ Captured log setup ------------------------------
DEBUG    peewee:peewee.py:3165 ('BEGIN', None)
DEBUG    peewee:peewee.py:3165 ('CREATE TABLE IF NOT EXISTS "cacheinfo" ("id" INTEGER NOT NULL PRIMARY KEY, "valid" INTEGER NOT NULL, "cache_key" TEXT NOT NULL, "parameter" TEXT, "last_ingestion_time" TEXT NOT NULL, "file_id" TEXT, "file_hash" TEXT, "size" INTEGER, "path" TEXT, "cache_permanently" INTEGER)', [])
DEBUG    peewee:peewee.py:3165 ('CREATE UNIQUE INDEX IF NOT EXISTS "cacheinfo_cache_key_parameter" ON "cacheinfo" ("cache_key", "parameter")', [])
DEBUG    peewee:peewee.py:3165 ('CREATE TABLE IF NOT EXISTS "artist" ("id" TEXT NOT NULL PRIMARY KEY, "name" TEXT, "album_count" INTEGER, "starred" TEXT, "biography" TEXT, "music_brainz_id" TEXT, "last_fm_url" TEXT, "_artist_image_url_id" INTEGER, FOREIGN KEY ("_artist_image_url_id") REFERENCES "cacheinfo" ("id"))', [])
DEBUG    peewee:peewee.py:3165 ('CREATE INDEX IF NOT EXISTS "artist__artist_image_url_id" ON "artist" ("_artist_image_url_id")', [])
DEBUG    peewee:peewee.py:3165 ('CREATE TABLE IF NOT EXISTS "genre" ("name" TEXT NOT NULL PRIMARY KEY, "song_count" INTEGER, "album_count" INTEGER)', [])
DEBUG    peewee:peewee.py:3165 ('CREATE TABLE IF NOT EXISTS "album" ("id" TEXT NOT NULL PRIMARY KEY, "created" TEXT, "duration" REAL, "name" TEXT, "play_count" INTEGER, "song_count" INTEGER, "starred" TEXT, "year" INTEGER, "artist_id" TEXT, "genre_id" TEXT, "_cover_art_id" INTEGER, FOREIGN KEY ("artist_id") REFERENCES "artist" ("id"), FOREIGN KEY ("genre_id") REFERENCES "genre" ("name"), FOREIGN KEY ("_cover_art_id") REFERENCES "cacheinfo" ("id"))', [])
DEBUG    peewee:peewee.py:3165 ('CREATE INDEX IF NOT EXISTS "album_artist_id" ON "album" ("artist_id")', [])
DEBUG    peewee:peewee.py:3165 ('CREATE INDEX IF NOT EXISTS "album_genre_id" ON "album" ("genre_id")', [])
DEBUG    peewee:peewee.py:3165 ('CREATE INDEX IF NOT EXISTS "album__cover_art_id" ON "album" ("_cover_art_id")', [])
DEBUG    peewee:peewee.py:3165 ('CREATE TABLE IF NOT EXISTS "albumqueryresult" ("query_hash" TEXT NOT NULL PRIMARY KEY)', [])
DEBUG    peewee:peewee.py:3165 ('CREATE TABLE IF NOT EXISTS "albumqueryresult_album_through" ("id" INTEGER NOT NULL PRIMARY KEY, "albumqueryresult_id" TEXT NOT NULL, "album_id" TEXT NOT NULL, "position" INTEGER NOT NULL, FOREIGN KEY ("albumqueryresult_id") REFERENCES "albumqueryresult" ("query_hash"), FOREIGN KEY ("album_id") REFERENCES "album" ("id"))', [])
DEBUG    peewee:peewee.py:3165 ('CREATE INDEX IF NOT EXISTS "albumqueryresultalbumthrough_albumqueryresult_id" ON "albumqueryresult_album_through" ("albumqueryresult_id")', [])
DEBUG    peewee:peewee.py:3165 ('CREATE INDEX IF NOT EXISTS "albumqueryresultalbumthrough_album_id" ON "albumqueryresult_album_through" ("album_id")', [])
DEBUG    peewee:peewee.py:3165 ('CREATE UNIQUE INDEX IF NOT EXISTS "albumqueryresultalbumthrough_albumqueryresult_id_album_i_a4f72d2" ON "albumqueryresult_album_through" ("albumqueryresult_id", "album_id", "position")', [])
DEBUG    peewee:peewee.py:3165 ('CREATE TABLE IF NOT EXISTS "directory" ("id" TEXT NOT NULL PRIMARY KEY, "name" TEXT, "parent_id" TEXT)', [])
DEBUG    peewee:peewee.py:3165 ('CREATE TABLE IF NOT EXISTS "ignoredarticle" ("name" TEXT NOT NULL PRIMARY KEY)', [])
DEBUG    peewee:peewee.py:3165 ('CREATE TABLE IF NOT EXISTS "playlist" ("id" TEXT NOT NULL PRIMARY KEY, "name" TEXT NOT NULL, "comment" TEXT, "owner" TEXT, "song_count" INTEGER, "duration" REAL, "created" TEXT, "changed" TEXT, "public" INTEGER, "_cover_art_id" INTEGER, FOREIGN KEY ("_cover_art_id") REFERENCES "cacheinfo" ("id"))', [])
DEBUG    peewee:peewee.py:3165 ('CREATE INDEX IF NOT EXISTS "playlist__cover_art_id" ON "playlist" ("_cover_art_id")', [])
DEBUG    peewee:peewee.py:3165 ('CREATE TABLE IF NOT EXISTS "song" ("id" TEXT NOT NULL PRIMARY KEY, "title" TEXT NOT NULL, "duration" REAL, "parent_id" TEXT, "album_id" TEXT, "artist_id" TEXT, "genre_id" TEXT, "file_id" INTEGER, "_cover_art_id" INTEGER, "track" INTEGER, "disc_number" INTEGER, "year" INTEGER, "user_rating" INTEGER, "starred" TEXT, FOREIGN KEY ("album_id") REFERENCES "album" ("id"), FOREIGN KEY ("artist_id") REFERENCES "artist" ("id"), FOREIGN KEY ("genre_id") REFERENCES "genre" ("name"), FOREIGN KEY ("file_id") REFERENCES "cacheinfo" ("id"), FOREIGN KEY ("_cover_art_id") REFERENCES "cacheinfo" ("id"))', [])
DEBUG    peewee:peewee.py:3165 ('CREATE INDEX IF NOT EXISTS "song_album_id" ON "song" ("album_id")', [])
DEBUG    peewee:peewee.py:3165 ('CREATE INDEX IF NOT EXISTS "song_artist_id" ON "song" ("artist_id")', [])
DEBUG    peewee:peewee.py:3165 ('CREATE INDEX IF NOT EXISTS "song_genre_id" ON "song" ("genre_id")', [])
DEBUG    peewee:peewee.py:3165 ('CREATE INDEX IF NOT EXISTS "song_file_id" ON "song" ("file_id")', [])
DEBUG    peewee:peewee.py:3165 ('CREATE INDEX IF NOT EXISTS "song__cover_art_id" ON "song" ("_cover_art_id")', [])
DEBUG    peewee:peewee.py:3165 ('CREATE TABLE IF NOT EXISTS "playlist_song_through" ("id" INTEGER NOT NULL PRIMARY KEY, "playlist_id" TEXT NOT NULL, "song_id" TEXT NOT NULL, "position" INTEGER NOT NULL, FOREIGN KEY ("playlist_id") REFERENCES "playlist" ("id"), FOREIGN KEY ("song_id") REFERENCES "song" ("id"))', [])
DEBUG    peewee:peewee.py:3165 ('CREATE INDEX IF NOT EXISTS "playlistsongthrough_playlist_id" ON "playlist_song_through" ("playlist_id")', [])
DEBUG    peewee:peewee.py:3165 ('CREATE INDEX IF NOT EXISTS "playlistsongthrough_song_id" ON "playlist_song_through" ("song_id")', [])
DEBUG    peewee:peewee.py:3165 ('CREATE UNIQUE INDEX IF NOT EXISTS "playlistsongthrough_playlist_id_song_id_position" ON "playlist_song_through" ("playlist_id", "song_id", "position")', [])
DEBUG    peewee:peewee.py:3165 ('CREATE TABLE IF NOT EXISTS "similarartist" ("id" INTEGER NOT NULL PRIMARY KEY, "artist_id" TEXT NOT NULL, "similar_artist_id" TEXT NOT NULL, "order" INTEGER NOT NULL, FOREIGN KEY ("artist_id") REFERENCES "artist" ("id"), FOREIGN KEY ("similar_artist_id") REFERENCES "artist" ("id"))', [])
DEBUG    peewee:peewee.py:3165 ('CREATE INDEX IF NOT EXISTS "similarartist_artist_id" ON "similarartist" ("artist_id")', [])
DEBUG    peewee:peewee.py:3165 ('CREATE INDEX IF NOT EXISTS "similarartist_similar_artist_id" ON "similarartist" ("similar_artist_id")', [])
DEBUG    peewee:peewee.py:3165 ('CREATE UNIQUE INDEX IF NOT EXISTS "similarartist_artist_id_similar_artist_id_order" ON "similarartist" ("artist_id", "similar_artist_id", "order")', [])
DEBUG    peewee:peewee.py:3165 ('CREATE TABLE IF NOT EXISTS "version" ("id" INTEGER NOT NULL PRIMARY KEY, "major" INTEGER NOT NULL, "minor" INTEGER NOT NULL, "patch" INTEGER NOT NULL)', [])
------------------------------ Captured log call -------------------------------
DEBUG    peewee:peewee.py:3165 ('SELECT "t1"."id", "t1"."name", "t1"."parent_id" FROM "directory" AS "t1" WHERE ("t1"."id" = ?) LIMIT ? OFFSET ?', ['d1', 1, 0])
DEBUG    peewee:peewee.py:3165 ('SELECT "t1"."id", "t1"."valid", "t1"."cache_key", "t1"."parameter", "t1"."last_ingestion_time", "t1"."file_id", "t1"."file_hash", "t1"."size", "t1"."path", "t1"."cache_permanently" FROM "cacheinfo" AS "t1" WHERE ((("t1"."cache_key" = ?) AND ("t1"."parameter" = ?)) AND ("t1"."valid" = ?)) LIMIT ? OFFSET ?', ['directory', 'd1', True, 1, 0])
---------------------------- Captured log teardown -----------------------------
INFO     root:adapter.py:88 Shutdown complete

Looking at the Debian CI logs, I think this issue is caused by a more recent version of dataclasses-json than you are currently building with. Your requirements.txt file says you are using 0.5.7 whereas I'm building with 0.5.13 (and working on updating the Debian package to 0.6.0....)

@baldurmen
Copy link
Author

The issue doesn't seem to break anything obvious though, as 0.12.0 runs well on my side.

fabaff pushed a commit to NixOS/nixpkgs that referenced this issue May 16, 2024
I did a few things here:

- Removed the call to `xvfb-run`, it's no longer needed after upstream
  removed its ui tests: sublime-music/sublime-music@bd573a0
- Unpin `dataclasses-json`. This fixes
  #311270.
  It was pinned in
  8780d5e
  with no explanation. When unpinning, I discovered that sublime-music's tests
  fail when run with the latest version of `dataclasses-music`. There's
  already an issue filed upstream about this:
  sublime-music/sublime-music#439
  - To work around this, I switched to using `pytestCheckHook` and added
    `test_get_music_directory` to `disabledTests`.
- Unpin `semver`. It was pinned in
  ac848b1
  with no explanation. This isn't necessary to fix the build, but it
  felt like good hygiene while I was in here (we shouldn't be
  pinning things without an explanation *why* they're pinned).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant