Skip to content

Commit 83bcc44

Browse files
authored
Fix the CI (#581)
1 parent 682347d commit 83bcc44

7 files changed

Lines changed: 1276 additions & 1022 deletions

File tree

.github/workflows/tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
- name: 🏗 Install dependencies
3838
run: poetry install --no-interaction
3939
- name: 🚀 Run pytest
40-
run: poetry run pytest --cov vehicle tests
40+
run: poetry run pytest --cov youtubeaio tests
4141
- name: ⬆️ Upload coverage artifact
4242
uses: actions/upload-artifact@v4.6.2
4343
with:

poetry.lock

Lines changed: 1131 additions & 1017 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,65 @@
11
# serializer version: 1
22
# name: test_fetch_video
3-
YouTubeVideo(video_id='Ks-_Mh1QhMc', nullable_snippet=YouTubeVideoSnippet(published_at=datetime.datetime(2012, 10, 1, 15, 27, 35, tzinfo=TzInfo(UTC)), channel_id='UCAuUUnT6oDeKwE6v1NGQxug', title='Your body language may shape who you are | Amy Cuddy', description='Body language affects how others see us, but it may also change how we see ourselves. Social psychologist Amy Cuddy argues that "power posing" -- standing in a posture of confidence, even when we don\'t feel confident -- can boost feelings of confidence, and might have an impact on our chances for success. (Note: Some of the findings presented in this talk have been referenced in an ongoing debate among social scientists about robustness and reproducibility. Read Amy Cuddy\'s response here: http://ideas.ted.com/inside-the-debate-about-power-posing-a-q-a-with-amy-cuddy/)\n\nGet TED Talks recommended just for you! Learn more at https://www.ted.com/signup.\n\nThe TED Talks channel features the best talks and performances from the TED Conference, where the world\'s leading thinkers and doers give the talk of their lives in 18 minutes (or less). Look for talks on Technology, Entertainment and Design -- plus science, business, global issues, the arts and more.\n\nFollow TED on Twitter: http://www.twitter.com/TEDTalks\nLike TED on Facebook: https://www.facebook.com/TED\n\nSubscribe to our channel: https://www.youtube.com/TED', thumbnails=YouTubeVideoThumbnails(default=YouTubeThumbnail(url='https://i.ytimg.com/vi/Ks-_Mh1QhMc/default.jpg', width=120, height=90), medium=YouTubeThumbnail(url='https://i.ytimg.com/vi/Ks-_Mh1QhMc/mqdefault.jpg', width=320, height=180), high=YouTubeThumbnail(url='https://i.ytimg.com/vi/Ks-_Mh1QhMc/hqdefault.jpg', width=480, height=360), standard=YouTubeThumbnail(url='https://i.ytimg.com/vi/Ks-_Mh1QhMc/sddefault.jpg', width=640, height=480), maxres=YouTubeThumbnail(url='https://i.ytimg.com/vi/Ks-_Mh1QhMc/maxresdefault.jpg', width=1280, height=720)), channel_title='TED', tags=['Amy Cuddy', 'TED', 'TEDTalk', 'TEDTalks', 'TED Talk', 'TED Talks', 'TEDGlobal', 'brain', 'business', 'psychology', 'self', 'success'], live_broadcast_content=<LiveBroadcastContent.NONE: 'none'>, default_language='en', default_audio_language='en'), nullable_content_details=YouTubeVideoContentDetails(raw_duration='PT21M3S', dimension=<VideoDimension.D2: '2d'>, definition=<VideoDefinition.HD: 'hd'>, raw_caption='true', licensed_content=True, projection=<VideoProjection.RECTANGULAR: 'rectangular'>))
3+
dict({
4+
'nullable_content_details': dict({
5+
'definition': <VideoDefinition.HD: 'hd'>,
6+
'dimension': <VideoDimension.D2: '2d'>,
7+
'licensed_content': True,
8+
'projection': <VideoProjection.RECTANGULAR: 'rectangular'>,
9+
'raw_caption': 'true',
10+
'raw_duration': 'PT21M3S',
11+
}),
12+
'nullable_snippet': dict({
13+
'channel_id': 'UCAuUUnT6oDeKwE6v1NGQxug',
14+
'channel_title': 'TED',
15+
'default_audio_language': 'en',
16+
'default_language': 'en',
17+
'description': 'Body language affects how others see us, but it may also change how we see ourselves. Social psychologist Amy Cuddy argues that "power posing" -- standing in a posture of confidence, even when we don\'t feel confident -- can boost feelings of confidence, and might have an impact on our chances for success. (Note: Some of the findings presented in this talk have been referenced in an ongoing debate among social scientists about robustness and reproducibility. Read Amy Cuddy\'s response here: http://ideas.ted.com/inside-the-debate-about-power-posing-a-q-a-with-amy-cuddy/)Get TED Talks recommended just for you! Learn more at https://www.ted.com/signup.The TED Talks channel features the best talks and performances from the TED Conference, where the world\'s leading thinkers and doers give the talk of their lives in 18 minutes (or less). Look for talks on Technology, Entertainment and Design -- plus science, business, global issues, the arts and more.Follow TED on Twitter: http://www.twitter.com/TEDTalksLike TED on Facebook: https://www.facebook.com/TEDSubscribe to our channel: https://www.youtube.com/TED',
18+
'live_broadcast_content': <LiveBroadcastContent.NONE: 'none'>,
19+
'published_at': datetime.datetime(2012, 10, 1, 15, 27, 35, tzinfo=TzInfo(0)),
20+
'tags': list([
21+
'Amy Cuddy',
22+
'TED',
23+
'TEDTalk',
24+
'TEDTalks',
25+
'TED Talk',
26+
'TED Talks',
27+
'TEDGlobal',
28+
'brain',
29+
'business',
30+
'psychology',
31+
'self',
32+
'success',
33+
]),
34+
'thumbnails': dict({
35+
'default': dict({
36+
'height': 90,
37+
'url': 'https://i.ytimg.com/vi/Ks-_Mh1QhMc/default.jpg',
38+
'width': 120,
39+
}),
40+
'high': dict({
41+
'height': 360,
42+
'url': 'https://i.ytimg.com/vi/Ks-_Mh1QhMc/hqdefault.jpg',
43+
'width': 480,
44+
}),
45+
'maxres': dict({
46+
'height': 720,
47+
'url': 'https://i.ytimg.com/vi/Ks-_Mh1QhMc/maxresdefault.jpg',
48+
'width': 1280,
49+
}),
50+
'medium': dict({
51+
'height': 180,
52+
'url': 'https://i.ytimg.com/vi/Ks-_Mh1QhMc/mqdefault.jpg',
53+
'width': 320,
54+
}),
55+
'standard': dict({
56+
'height': 480,
57+
'url': 'https://i.ytimg.com/vi/Ks-_Mh1QhMc/sddefault.jpg',
58+
'width': 640,
59+
}),
60+
}),
61+
'title': 'Your body language may shape who you are | Amy Cuddy',
62+
}),
63+
'video_id': 'Ks-_Mh1QhMc',
64+
})
465
# ---

tests/conftest.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"""Pytest configuration for Syrupy snapshot testing with Youtube extension."""
2+
3+
import pytest
4+
5+
from syrupy import SnapshotAssertion
6+
from tests.syrupy import YoutubeSnapshotExtension
7+
8+
9+
@pytest.fixture(name="snapshot")
10+
def snapshot_assertion(snapshot: SnapshotAssertion) -> SnapshotAssertion:
11+
"""Return snapshot assertion fixture with the Youtube extension."""
12+
return snapshot.use_extension(YoutubeSnapshotExtension)

tests/fixtures/video/1/snippet.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"publishedAt": "2012-10-01T15:27:35Z",
33
"channelId": "UCAuUUnT6oDeKwE6v1NGQxug",
44
"title": "Your body language may shape who you are | Amy Cuddy",
5-
"description": "Body language affects how others see us, but it may also change how we see ourselves. Social psychologist Amy Cuddy argues that \"power posing\" -- standing in a posture of confidence, even when we don't feel confident -- can boost feelings of confidence, and might have an impact on our chances for success. (Note: Some of the findings presented in this talk have been referenced in an ongoing debate among social scientists about robustness and reproducibility. Read Amy Cuddy's response here: http://ideas.ted.com/inside-the-debate-about-power-posing-a-q-a-with-amy-cuddy/)\n\nGet TED Talks recommended just for you! Learn more at https://www.ted.com/signup.\n\nThe TED Talks channel features the best talks and performances from the TED Conference, where the world's leading thinkers and doers give the talk of their lives in 18 minutes (or less). Look for talks on Technology, Entertainment and Design -- plus science, business, global issues, the arts and more.\n\nFollow TED on Twitter: http://www.twitter.com/TEDTalks\nLike TED on Facebook: https://www.facebook.com/TED\n\nSubscribe to our channel: https://www.youtube.com/TED",
5+
"description": "Body language affects how others see us, but it may also change how we see ourselves. Social psychologist Amy Cuddy argues that \"power posing\" -- standing in a posture of confidence, even when we don't feel confident -- can boost feelings of confidence, and might have an impact on our chances for success. (Note: Some of the findings presented in this talk have been referenced in an ongoing debate among social scientists about robustness and reproducibility. Read Amy Cuddy's response here: http://ideas.ted.com/inside-the-debate-about-power-posing-a-q-a-with-amy-cuddy/)Get TED Talks recommended just for you! Learn more at https://www.ted.com/signup.The TED Talks channel features the best talks and performances from the TED Conference, where the world's leading thinkers and doers give the talk of their lives in 18 minutes (or less). Look for talks on Technology, Entertainment and Design -- plus science, business, global issues, the arts and more.Follow TED on Twitter: http://www.twitter.com/TEDTalksLike TED on Facebook: https://www.facebook.com/TEDSubscribe to our channel: https://www.youtube.com/TED",
66
"thumbnails": {
77
"default": {
88
"url": "https://i.ytimg.com/vi/Ks-_Mh1QhMc/default.jpg",
@@ -50,7 +50,7 @@
5050
"defaultLanguage": "en",
5151
"localized": {
5252
"title": "Your body language may shape who you are | Amy Cuddy",
53-
"description": "Body language affects how others see us, but it may also change how we see ourselves. Social psychologist Amy Cuddy argues that \"power posing\" -- standing in a posture of confidence, even when we don't feel confident -- can boost feelings of confidence, and might have an impact on our chances for success. (Note: Some of the findings presented in this talk have been referenced in an ongoing debate among social scientists about robustness and reproducibility. Read Amy Cuddy's response here: http://ideas.ted.com/inside-the-debate-about-power-posing-a-q-a-with-amy-cuddy/)\n\nGet TED Talks recommended just for you! Learn more at https://www.ted.com/signup.\n\nThe TED Talks channel features the best talks and performances from the TED Conference, where the world's leading thinkers and doers give the talk of their lives in 18 minutes (or less). Look for talks on Technology, Entertainment and Design -- plus science, business, global issues, the arts and more.\n\nFollow TED on Twitter: http://www.twitter.com/TEDTalks\nLike TED on Facebook: https://www.facebook.com/TED\n\nSubscribe to our channel: https://www.youtube.com/TED"
53+
"description": "Body language affects how others see us, but it may also change how we see ourselves. Social psychologist Amy Cuddy argues that \"power posing\" -- standing in a posture of confidence, even when we don't feel confident -- can boost feelings of confidence, and might have an impact on our chances for success. (Note: Some of the findings presented in this talk have been referenced in an ongoing debate among social scientists about robustness and reproducibility. Read Amy Cuddy's response here: http://ideas.ted.com/inside-the-debate-about-power-posing-a-q-a-with-amy-cuddy/)Get TED Talks recommended just for you! Learn more at https://www.ted.com/signup.The TED Talks channel features the best talks and performances from the TED Conference, where the world's leading thinkers and doers give the talk of their lives in 18 minutes (or less). Look for talks on Technology, Entertainment and Design -- plus science, business, global issues, the arts and more.Follow TED on Twitter: http://www.twitter.com/TEDTalksLike TED on Facebook: https://www.facebook.com/TEDSubscribe to our channel: https://www.youtube.com/TED"
5454
},
5555
"defaultAudioLanguage": "en"
5656
}

tests/syrupy.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
"""Tests for the YouTube client."""
2+
3+
from __future__ import annotations
4+
5+
from typing import TYPE_CHECKING, Any
6+
7+
from pydantic import BaseModel
8+
from syrupy.extensions import AmberSnapshotExtension
9+
from syrupy.extensions.amber import AmberDataSerializer
10+
11+
if TYPE_CHECKING:
12+
from syrupy.types import (
13+
PropertyFilter,
14+
PropertyMatcher,
15+
PropertyPath,
16+
SerializableData,
17+
)
18+
19+
20+
class YoutubeSnapshotSerializer(AmberDataSerializer):
21+
"""Youtube snapshot serializer for Syrupy.
22+
23+
Handles special cases for Youtube data structures.
24+
"""
25+
26+
@classmethod
27+
def _serialize( # pylint: disable=too-many-arguments
28+
cls,
29+
data: SerializableData,
30+
*,
31+
depth: int = 0,
32+
exclude: PropertyFilter | None = None,
33+
include: PropertyFilter | None = None,
34+
matcher: PropertyMatcher | None = None,
35+
path: PropertyPath = (),
36+
visited: set[Any] | None = None,
37+
) -> str:
38+
"""Pre-process data before serializing.
39+
40+
This allows us to handle specific cases for
41+
Youtube data structures.
42+
"""
43+
serializable_data = data
44+
if isinstance(data, BaseModel):
45+
serializable_data = data.model_dump()
46+
47+
return super()._serialize(
48+
serializable_data,
49+
depth=depth,
50+
exclude=exclude,
51+
include=include,
52+
matcher=matcher,
53+
path=path,
54+
visited=visited,
55+
)
56+
57+
58+
class YoutubeSnapshotExtension(AmberSnapshotExtension):
59+
"""Youtube extension for Syrupy."""
60+
61+
VERSION = "1"
62+
"""Current version of serialization format.
63+
64+
Need to be bumped when we change the YoutubeSnapshotSerializer.
65+
"""
66+
67+
serializer_class: type[AmberDataSerializer] = YoutubeSnapshotSerializer

tests/test_video.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import pytest
88
from aiohttp.web_request import BaseRequest
99
from aresponses import Response, ResponsesMockServer
10-
from syrupy import SnapshotAssertion
1110

11+
from syrupy import SnapshotAssertion
1212
from youtubeaio.helper import first
1313
from youtubeaio.models import YouTubeVideoThumbnails
1414
from youtubeaio.types import PartMissingError

0 commit comments

Comments
 (0)