import datetime from nebula_rss import __version__, NebulaLoader def test_version(): assert __version__ == '0.2.0' def test_video_parsing(): example_response = { 'type': 'video_episode', 'slug': 'wendover-electric-vehicles-battery-problem', 'title': "Electric Vehicles' Battery Problem", 'description': 'Watch Extremities at http://youtube.com/extremities\n\nBuy a Wendover Productions t-shirt: https://standard.tv/collections/wendover-productions/products/wendover-productions-shirt\n\nSubscribe to Half as Interesting (The other channel from Wendover Productions): https://www.youtube.com/halfasinteresting\n\nYoutube: http://www.YouTube.com/WendoverProductions\nInstagram: http://Instagram.com/sam.from.wendover\nTwitter: http://www.Twitter.com/WendoverPro\nSponsorship Enquiries: wendover@standard.tv\nOther emails: sam@wendover.productions\nReddit: http://Reddit.com/r/WendoverProductions\n\nWriting by Sam Denby\nEditing by Alexander Williard\nAnimation by Josh Sherrington\nSound by Graham Haerther \nThumbnail by Simon Buckmaster\n\n[1] https://lighthouse.mq.edu.au/article/july-2020/please-explain-how-lithium-became-a-rock-star\n[2] https://www.forbes.com/sites/rrapier/2020/12/13/the-worlds-top-lithium-producers/?sh=378a13bb5bc6\n[3] https://www.statista.com/statistics/235323/lithium-batteries-top-manufacturers/\n[4] https://www.spglobal.com/platts/en/market-insights/latest-news/energy-transition/121421-commodities-2022-global-lithium-market-to-remain-tight-into-2022\n[5] https://tradingeconomics.com/commodity/cobalt\n[6] https://tradingeconomics.com/commodity/nickel\n[7] https://pubs.usgs.gov/periodicals/mcs2021/mcs2021-lithium.pdf\n[8] https://eplanning.blm.gov/public_projects/1503166/200352542/20030633/250036832/Thacker%20Pass_FEIS_Chapters1-6_508.pdf#page=57\n[9] https://www.nytimes.com/2021/05/06/business/lithium-mining-race.html\n[10] http://gbrw.org/wp-content/uploads/2021/02/Thacker-Pass-PR-final.pdf\n[11] https://www.sierranevadaally.org/2021/05/20/people-of-red-mountain-statement-of-opposition-to-lithium-nevada-corps-proposed-thacker-pass-open-pit-lithium-mine/\n[12] https://thisisreno.com/2021/11/judge-says-no-evidence-of-massacre-at-proposed-mine-site-tribes-say-otherwise/\n[13] https://www.statista.com/statistics/264928/cobalt-mine-production-by-country/\n[14] https://www.spglobal.com/platts/en/market-insights/latest-news/metals/022421-uk-cobalt-free-solid-state-battery-technology-claims-major-cost-efficiencies\n[15] https://www.latimes.com/business/story/2021-11-15/drilling-for-white-gold-is-happening-right-now-at-the-salton-sea', # noqa 'short_description': "Electric Vehicles' Battery Problem", 'duration': 970, 'published_at': '2022-01-11T15:03:33Z', 'channel_slug': 'wendover', 'channel_slugs': ['wendover'], 'channel_title': 'Wendover', 'category_slugs': ['explainers'], 'assets': { 'channel_avatar': { '16': { 'original': 'https://images.watchnebula.com/p/e040f576-82c5-401d-a754-1600483dc673.jpeg?width=16&', 'webp': 'https://images.watchnebula.com/p/e040f576-82c5-401d-a754-1600483dc673.webp?width=16&' }, '32': { 'original': 'https://images.watchnebula.com/p/e040f576-82c5-401d-a754-1600483dc673.jpeg?width=32&', 'webp': 'https://images.watchnebula.com/p/e040f576-82c5-401d-a754-1600483dc673.webp?width=32&' }, '64': { 'original': 'https://images.watchnebula.com/p/e040f576-82c5-401d-a754-1600483dc673.jpeg?width=64&', 'webp': 'https://images.watchnebula.com/p/e040f576-82c5-401d-a754-1600483dc673.webp?width=64&' }, '128': { 'original': 'https://images.watchnebula.com/p/e040f576-82c5-401d-a754-1600483dc673.jpeg?width=128&', 'webp': 'https://images.watchnebula.com/p/e040f576-82c5-401d-a754-1600483dc673.webp?width=128&' }, '256': { 'original': 'https://images.watchnebula.com/p/e040f576-82c5-401d-a754-1600483dc673.jpeg?width=256&', 'webp': 'https://images.watchnebula.com/p/e040f576-82c5-401d-a754-1600483dc673.webp?width=256&' }, '512': { 'original': 'https://images.watchnebula.com/p/e040f576-82c5-401d-a754-1600483dc673.jpeg?width=512&', 'webp': 'https://images.watchnebula.com/p/e040f576-82c5-401d-a754-1600483dc673.webp?width=512&' } }, 'thumbnail': {'240': {'original': 'https://images.watchnebula.com/p/ffcd9296-2857-469d-9c00-1c7bace3407e.jpeg?height=240&', 'webp': 'https://images.watchnebula.com/p/ffcd9296-2857-469d-9c00-1c7bace3407e.webp?height=240&'}, '480': {'original': 'https://images.watchnebula.com/p/ffcd9296-2857-469d-9c00-1c7bace3407e.jpeg?height=480&', 'webp': 'https://images.watchnebula.com/p/ffcd9296-2857-469d-9c00-1c7bace3407e.webp?height=480&'}, '720': {'original': 'https://images.watchnebula.com/p/ffcd9296-2857-469d-9c00-1c7bace3407e.jpeg?height=720&', 'webp': 'https://images.watchnebula.com/p/ffcd9296-2857-469d-9c00-1c7bace3407e.webp?height=720&'}, '1080': {'original': 'https://images.watchnebula.com/p/ffcd9296-2857-469d-9c00-1c7bace3407e.jpeg?height=1080&', 'webp': 'https://images.watchnebula.com/p/ffcd9296-2857-469d-9c00-1c7bace3407e.webp?height=1080&'}}}, # noqa 'attributes': ['free_sample_eligible'], 'share_url': 'https://nebula.app/videos/wendover-electric-vehicles-battery-problem/', 'channel': None, 'engagement': None, 'zype_id': '61dd99e519d76400018b94b0' } video = NebulaLoader._parse_api_response(example_response) assert video.title == "Electric Vehicles' Battery Problem" assert video.creator == 'Wendover' assert video.url == 'https://nebula.app/videos/wendover-electric-vehicles-battery-problem/' assert video.release_at == datetime.datetime(2022, 1, 11, 15, 3, 33, tzinfo=datetime.timezone.utc) print(video)