def setUp(self): self.input_path = tempfile.TemporaryDirectory() tmp_dir = self.input_path.name with open(tmp_dir + "/episode1.mp3", "wb") as f: f.write(b"episode_1_mp3_content") with open(tmp_dir + "/episode2.mp3", "wb") as f: f.write(b"episode_2_mp3_content") self.author = Author(name="John Doe", email="*****@*****.**") self.episode1 = Episode( id=1, title="Episode 1", description="Episode 1: test.", audio_file=tmp_dir + "/episode1.mp3", ) self.episode2 = Episode( id=2, title="Episode 2", description="Episode 2: second test.", audio_file=tmp_dir + "/episode2.mp3", ) self.podcast = Podcast( title="Test podcast", subtitle="Test podcast subtitle.", description="Test podcast description.", author=self.author, episodes=[self.episode1, self.episode2], base_url="https://example.com", )
def setUp(self): self.author = Author(name="John Doe", email="*****@*****.**") self.episode1 = Episode( id=1, title="Episode 1", description="Episode 1: test.", audio_file="episode1.mp3", ) self.episode2 = Episode( id=2, title="Episode 2", description="Episode 2: second test.", audio_file="episode2.mp3", )
def __attrs_post_init__(self): podcast_config = yaml.load(self.yaml_str, Loader=yaml.Loader) pc = podcast_config["podcast"] author = Author(name=pc["author"]["name"], email=pc["author"]["email"]) episodes = [] id_count = 1 for episode in pc["episodes"]: episodes.append(Episode(id=id_count, **episode)) id_count += 1 self.podcast = Podcast( title=pc["title"], subtitle=pc["subtitle"], description=pc["description"], author=author, episodes=episodes, base_url=pc["base_url"], )
def setUp(self): self.author = Author(name="John Doe", email="*****@*****.**") self.episode1 = Episode( id=1, title="Episode 1", description="Episode 1: test.", audio_file="episode1.mp3", ) self.episode2 = Episode( id=2, title="Episode 2", description="Episode 2: second test.", audio_file="episode2.mp3", ) self.podcast = Podcast( title="Test podcast", subtitle="Test podcast subtitle.", description="Test podcast description.", author=self.author, episodes=[self.episode1, self.episode2], base_url="https://example.com", )
def test_init_author(self): author = Author(name="John Doe", email="*****@*****.**") self.assertEqual(author.name, "John Doe") self.assertEqual(author.email, "*****@*****.**")
def test_author_to_dict(self): author = Author(name="John Doe", email="*****@*****.**") self.assertEqual(author.to_dict(), { "name": "John Doe", "email": "*****@*****.**" })