-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MediaContainer
class is now a list (#1373)
* MediaContainer class is now a list - can now support totalSize as returned from server * add tests for media container * Update MediaContainer attributes if previously None when extending
- Loading branch information
Showing
2 changed files
with
109 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from plexapi.audio import Track | ||
from plexapi.base import MediaContainer | ||
|
||
|
||
def test_media_container_is_list(): | ||
container = MediaContainer(None, None, Track(None, None)) | ||
assert isinstance(container, list) | ||
assert len(container) == 1 | ||
container.append(Track(None, None)) | ||
assert len(container) == 2 | ||
|
||
|
||
def test_media_container_extend(): | ||
container_1 = MediaContainer(None, None, Track(None, None)) | ||
container_2 = MediaContainer( | ||
None, None, [Track(None, None), Track(None, None)] | ||
) | ||
container_1.size, container_2.size = 1, 2 | ||
container_1.offset, container_2.offset = 3, 4 | ||
container_1.totalSize = container_2.totalSize = 10 | ||
container_1.extend(container_2) | ||
assert container_1.size == 1 + 2 | ||
assert container_1.offset == min(3, 4) | ||
assert container_1.totalSize == 10 | ||
|
||
|
||
def test_fetch_items_with_media_container(show): | ||
all_episodes = show.episodes() | ||
some_episodes = show.episodes(maxresults=2) | ||
assert some_episodes.size == 2 | ||
assert some_episodes.offset == 0 | ||
assert some_episodes.totalSize == len(all_episodes) |