Skip to content

Commit 38683bb

Browse files
committed
build: upgrade moe to 2.0.0
1 parent b0fcb7e commit 38683bb

File tree

5 files changed

+17
-42
lines changed

5 files changed

+17
-42
lines changed

.github/scripts/prep_release.py

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import pathlib
1515
import re
1616
import subprocess
17+
from textwrap import indent
1718

1819
import github3
1920
from github3.repos import Repository
@@ -193,6 +194,8 @@ def generate_changelog(old_version: str, new_version: str) -> None:
193194
for commit in commits:
194195
if commit_type == commit.commit_type:
195196
changelog_body += str(commit) + "\n"
197+
if commit.breaking:
198+
changelog_body += "\n" + indent(commit.body, " ") + "\n"
196199

197200
changelog_body += "\n"
198201

moe_transcode/transcode_core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import moe
1212
from moe import config
1313
from moe.library import Album, Track
14-
from moe.plugins.move import fmt_item_path
14+
from moe.move import fmt_item_path
1515

1616
__all__ = ["I", "TranscodeFormat", "transcode"]
1717

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ readme = "README.rst"
99

1010
[tool.poetry.dependencies]
1111
python = ">=3.9,<3.12"
12-
moe = "^1.5.1"
12+
moe = "^2.0.0"
1313

1414
[tool.poetry.group.test.dependencies]
1515
debugpy = "^1.4.1"

tests/conftest.py

+11-39
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
"""Shared pytest configuration."""
2+
23
import datetime
34
import importlib
45
import random
56
import shutil
67
import sys
78
import textwrap
89
from pathlib import Path
9-
from typing import Any, Callable, Iterator, Optional
10+
from typing import Callable, Iterator, Optional
1011
from unittest.mock import MagicMock
1112

13+
import moe.write
1214
import pytest
1315
import sqlalchemy as sa
1416
import sqlalchemy.exc
1517
import sqlalchemy.orm
1618
from moe import config
17-
from moe.config import Config, ExtraPlugin, MoeSession, session_factory
19+
from moe.config import Config, ExtraPlugin, moe_sessionmaker
1820
from moe.library import Album, Extra, Track
19-
from moe.plugins import write as moe_write
2021

2122
__all__ = ["album_factory", "extra_factory", "track_factory"]
2223

@@ -73,9 +74,7 @@ def tmp_config(
7374
Args:
7475
settings: Settings string to use. This has the same format as a normal
7576
``config.toml`` file.
76-
init_db: Whether or not to initialize the database.
77-
tmp_db: Whether or not to use a temporary (in-memory) database. If ``True``,
78-
the database will be initialized regardless of ``init_db``.
77+
tmp_db: Whether or not to use a temporary (in-memory) database.
7978
extra_plugins: Any additional plugins to enable.
8079
config_dir: Optionally specifiy a config directory to use.
8180
@@ -112,18 +111,16 @@ def _tmp_config(
112111
ExtraPlugin(importlib.import_module("moe_transcode"), "transcode")
113112
)
114113

115-
config = Config(
114+
return Config(
116115
config_dir=config_dir,
117116
settings_filename="config.toml",
118117
extra_plugins=extra_plugins,
119118
engine=engine,
120119
init_db=init_db,
121120
)
122121

123-
return config
124-
125122
yield _tmp_config
126-
session_factory.configure(bind=None) # reset the database in between tests
123+
moe_sessionmaker.configure(bind=None) # reset the database in between tests
127124

128125

129126
@pytest.fixture
@@ -137,22 +134,17 @@ def tmp_session(tmp_config) -> Iterator[sqlalchemy.orm.session.Session]:
137134
The temporary session.
138135
"""
139136
try:
140-
MoeSession().get_bind()
137+
moe_sessionmaker().get_bind()
141138
except sqlalchemy.exc.UnboundExecutionError:
142-
MoeSession.remove()
143139
tmp_config("default_plugins = []", tmp_db=True)
144140

145-
session = MoeSession()
146-
with session.begin():
141+
with moe_sessionmaker.begin() as session:
147142
yield session
148143

149-
MoeSession.remove()
150-
151144

152145
@pytest.fixture(autouse=True)
153146
def _clean_moe():
154-
"""Ensure we aren't sharing sessions or configs between tests."""
155-
MoeSession.remove()
147+
"""Ensure we aren't sharing configs between tests."""
156148
config.CONFIG = MagicMock()
157149

158150

@@ -161,7 +153,6 @@ def track_factory(
161153
exists: bool = False,
162154
dup_track: Optional[Track] = None,
163155
audio_format: str = "mp3",
164-
custom_fields: Optional[dict[str, Any]] = None,
165156
**kwargs,
166157
):
167158
"""Creates a track.
@@ -171,7 +162,6 @@ def track_factory(
171162
exists: Whether the track should exist on the filesystem. Note, this option
172163
requires the write plugin.
173164
dup_track: If given, the new track created will be a duplicate of `dup_track`.
174-
custom_fields: Dict of custom_fields to values to assign to the track.
175165
audio_format: Audio format of the track.
176166
**kwargs: Any other fields to assign to the Track.
177167
@@ -201,11 +191,6 @@ def track_factory(
201191
**kwargs,
202192
)
203193

204-
if custom_fields:
205-
for field, value in custom_fields.items():
206-
track.custom_fields.add(field)
207-
setattr(track, field, value)
208-
209194
if dup_track:
210195
for field in dup_track.fields:
211196
value = getattr(dup_track, field)
@@ -221,7 +206,7 @@ def track_factory(
221206
shutil.copyfile(EMPTY_FLAC_FILE, track.path)
222207
else:
223208
shutil.copyfile(EMPTY_MP3_FILE, track.path)
224-
moe_write.write_tags(track)
209+
moe.write.write_tags(track)
225210

226211
return track
227212

@@ -231,7 +216,6 @@ def extra_factory(
231216
path: Optional[Path] = None,
232217
exists: bool = False,
233218
dup_extra: Optional[Extra] = None,
234-
custom_fields: Optional[dict[str, Any]] = None,
235219
**kwargs,
236220
) -> Extra:
237221
"""Creates an extra for testing.
@@ -241,7 +225,6 @@ def extra_factory(
241225
path: Path to assign to the extra. Will create a random path if not given.
242226
exists: Whether the extra should actually exist on the filesystem.
243227
dup_extra: If given, the new extra created will be a duplicate of `dup_extra`.
244-
custom_fields: Dict of custom_fields to values to assign to the extra.
245228
**kwargs: Any other fields to assign to the extra.
246229
247230
Returns:
@@ -252,11 +235,6 @@ def extra_factory(
252235

253236
extra = Extra(album=album, path=path, **kwargs)
254237

255-
if custom_fields:
256-
for field, value in custom_fields.items():
257-
extra.custom_fields.add(field)
258-
setattr(extra, field, value)
259-
260238
if dup_extra:
261239
for field in dup_extra.fields:
262240
value = getattr(dup_extra, field)
@@ -279,7 +257,6 @@ def album_factory(
279257
exists: bool = False,
280258
dup_album: Optional[Album] = None,
281259
audio_format: str = "mp3",
282-
custom_fields: Optional[dict[str, Any]] = None,
283260
**kwargs,
284261
) -> Album:
285262
"""Creates an album.
@@ -292,7 +269,6 @@ def album_factory(
292269
requires the write plugin.
293270
dup_album: If given, the new album created will be a duplicate of `dup_album`.
294271
audio_format: Audio format of the tracks in the album.
295-
custom_fields: Dict of custom_fields to values to assign to the album.
296272
**kwargs: Any other fields to assign to the album.
297273
298274
Returns:
@@ -314,10 +290,6 @@ def album_factory(
314290
track_total=num_tracks,
315291
**kwargs,
316292
)
317-
if custom_fields:
318-
for field, value in custom_fields.items():
319-
album.custom_fields.add(field)
320-
setattr(album, field, value)
321293

322294
if dup_album:
323295
for field in dup_album.fields:

tests/test_transcode_core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import pytest
66
from moe import config
7-
from moe.plugins.move import fmt_item_path
7+
from moe.move import fmt_item_path
88

99
from moe_transcode import transcode
1010
from tests.conftest import album_factory, track_factory

0 commit comments

Comments
 (0)