def test_news(self): news = r.get_news(self.single_stock)[0] assert ('author' in news) assert ('num_clicks' in news) assert ('preview_image_url' in news) assert ('published_at' in news) assert ('relay_url' in news) assert ('source' in news) assert ('summary' in news) assert ('title' in news) assert ('updated_at' in news) assert ('url' in news) assert ('uuid' in news) assert ('related_instruments' in news) assert ('preview_text' in news) assert ('currency_id' in news) fake_news = r.get_news(self.fake_stock) assert (len(fake_news) == 0)
def test_news(self): news = r.get_news(self.single_stock)[0] self.assertIn('author', news) self.assertIn('num_clicks', news) self.assertIn('preview_image_url', news) self.assertIn('published_at', news) self.assertIn('relay_url', news) self.assertIn('source', news) self.assertIn('summary', news) self.assertIn('title', news) self.assertIn('updated_at', news) self.assertIn('url', news) self.assertIn('uuid', news) self.assertIn('related_instruments', news) self.assertIn('preview_text', news) self.assertIn('currency_id', news) fake_news = r.get_news(self.fake_stock) self.assertEqual(len(fake_news), 0)
def _get_news(self): """ Returns any news data. """ news = robin_stocks.get_news(self.symbol) print(news)
def get_news_formatted(ticker): articles = rs.get_news(ticker) news = [] for article in articles: news.append(f'{ticker} -- {article["published_at"]} -- {article["title"]} \n {article["url"]}') return news