def extract_topics(topics): """Creates a list of topics from a given list.""" topics_list = [] for topic in topics: if topic: topics_list.append(Topic(name=str(topic))) return topics_list
def test_add_speaker(self): topic = Topic(name="Python", description="", abbreviation="py") diversification = Diversity(name="speaker", description="description") speaker = Speaker( name="Kyle Harrison", avatar="https://avatar.com", bio="description", contact="apoclyps", role="Software Engineer", topics=[topic], diversification=[diversification], location="Belfast", source="test", ) db.session.add(speaker) db.session.commit() self.assertEqual(speaker.name, "Kyle Harrison") self.assertEqual(speaker.avatar, "https://avatar.com") self.assertEqual(speaker.bio, "description") self.assertEqual(speaker.contact, "apoclyps") self.assertEqual(speaker.role, "Software Engineer") self.assertEqual(speaker.topics, [topic]) self.assertEqual(speaker.diversification, [diversification]) self.assertEqual(speaker.location, "Belfast") self.assertEqual(speaker.source, "test")
def test_add_event(self): topic = Topic(name="Python", description="", abbreviation="py") entry = Entry(type="ticket", description="description") event = Event( name="learning new technologies", description="example description", url="https://example.com", start="2018-06-06 16:15:00Z", end="2018-06-06 17:15:00Z", duration=100000, topics=[topic], entry=[entry], category="test category", source="test", location="belfast", ) db.session.add(event) db.session.commit() self.assertEqual(event.name, "learning new technologies") self.assertEqual(event.description, "example description") self.assertEqual(event.url, "https://example.com") self.assertEqual(event.start, datetime(2018, 6, 6, 16, 15, 00)) self.assertEqual(event.end, datetime(2018, 6, 6, 17, 15, 00)) self.assertEqual(event.duration, 100000) self.assertEqual(event.category, "test category") self.assertEqual(event.location, "belfast")
def test_add_video(self): topic = Topic(name="Python", description="", abbreviation="py") channel = Channel(name="test", url="", description="", topics=[topic], source="test") video = Video( name= "Stone Age To Serverless or: How I Learned To Stop Worrying And Love The Platform", url="https://www.youtube.com/watch?v=cU-TGiWK-dc", description= "Due to a last-minute speaker dropout, Mark will be improvising on a theme", topics=[topic], channel=[channel], source="youtube", ) db.session.add(video) db.session.commit() self.assertEqual( video.name, "Stone Age To Serverless or: How I Learned To Stop Worrying And Love The Platform", ) self.assertEqual(video.url, "https://www.youtube.com/watch?v=cU-TGiWK-dc") self.assertEqual(video.channel, [channel]) self.assertEqual(video.source, "youtube")
def test_add(self): topic = Topic(name="Python", description="", abbreviation="py") entry = Entry(type="ticket", description="description") event = Event( name="learning new technologies", description="example description", url="https://example.com", start="2018-06-06 16:15:00Z", end="2018-06-06 17:15:00Z", duration=100000, topics=[topic], entry=[entry], category="test category", source="test", location="belfast", ) channel = Channel(name="test", url="", description="", topics=[topic], source="test") meetup = Meetup( name="learning new technologies", logo="https://example.com/image", url="https://example.com/meetup", description="the new shiny", topics=[topic], events=[event], channel=[channel], source="test", ) db.session.add(event) db.session.commit() self.assertEqual(meetup.name, "learning new technologies") self.assertEqual(meetup.logo, "https://example.com/image") self.assertEqual(meetup.url, "https://example.com/meetup") self.assertEqual(meetup.description, "the new shiny") self.assertEqual(len(meetup.topics), 1) self.assertEqual(len(meetup.events), 1) self.assertEqual(len(meetup.channel), 1)
def test_add_developer(self): topic = Topic(name="Python", description="", abbreviation="py") developer = Developer( avatar="https://avatars1.githubusercontent.com/u/1443700?s=400&v=4", login="******", name="Kyle Harrison", gists=2, repositories=36, url="https://api.github.com/users/apoclyps", followers=15, company="@Muxer", blog="http://kyleharrison.co.uk", bio="Maker, Mentor, Geeky Dad", topics=[topic], location="Belfast", source="test", ) db.session.add(developer) db.session.commit() self.assertEqual(developer.name, "Kyle Harrison") self.assertEqual( developer.avatar, "https://avatars1.githubusercontent.com/u/1443700?s=400&v=4", ) self.assertEqual(developer.login, "apoclyps") self.assertEqual(developer.gists, 2) self.assertEqual(developer.repositories, 36) self.assertEqual(developer.followers, 15) self.assertEqual(developer.company, "@Muxer") self.assertEqual(developer.blog, "http://kyleharrison.co.uk") self.assertEqual(developer.url, "https://api.github.com/users/apoclyps") self.assertEqual(developer.bio, "Maker, Mentor, Geeky Dad") self.assertEqual(developer.topics, [topic]) self.assertEqual(developer.location, "Belfast") self.assertEqual(developer.source, "test")
def extract_topics(topics): """Creates a list of topics from a given list.""" return [Topic(name=str(topic)) for topic in topics if topic]