Skip to content

Commit 4ba7ce5

Browse files
committed
REMOVE unnecessary code parts;
UPDATE feed test file with new feed mock; UPDATE readme file
1 parent ec47831 commit 4ba7ce5

4 files changed

Lines changed: 12 additions & 16 deletions

File tree

Narek Arsenyan/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
```json
4545
{
4646
"source_title": "Feed source title",
47+
"source_url": "Feed source url",
4748
"title": "Title of the new",
4849
"date": "Publishing date of the new",
4950
"link": "Link of the new",
@@ -96,7 +97,7 @@ Inside `.json` file is JSON object where keys are fetched feeds' sources and val
9697
```json
9798
{
9899
"https://timesofindia.indiatimes.com/rssfeedstopstories.cms": [
99-
"{\n \"source_title\": null,\n \"title\": \"Presidential polls: Mamata invites 22 oppn CMs, leaders for joint meeting on June 15\",\n \"date\": \"2022-06-11T16:22:36+05:30\",\n \"link\": \"https://timesofindia.indiatimes.com/india/presidential-polls-mamata-invites-22-oppn-cms-leaders-for-joint-meeting-on-june-15/articleshow/92146582.cms\",\n \"content\": \"With the Rajya Sabha results exposing dissension and lack of cohesion among opposition parties, West Bengal chief minister Mamata Banerjee on Saturday reached out to her counterparts and other leaders to participate in a meeting in Delhi on June 15 to discuss the upcoming presidential polls, which are scheduled for July 18.\",\n \"non_media_links\": [\n {\n \"href\": \"https://timesofindia.indiatimes.com/india/presidential-polls-mamata-invites-22-oppn-cms-leaders-for-joint-meeting-on-june-15/articleshow/92146582.cms\",\n \"link_type\": \"link\"\n }\n ],\n \"media_links\": []\n}"
100+
"{\n \"source_title\": Times of India,\n \"source_url\": \"https://timesofindia.indiatimes.com/rssfeedstopstories.cms\",\n \"title\": \"Presidential polls: Mamata invites 22 oppn CMs, leaders for joint meeting on June 15\",\n \"date\": \"2022-06-11T16:22:36+05:30\",\n \"link\": \"https://timesofindia.indiatimes.com/india/presidential-polls-mamata-invites-22-oppn-cms-leaders-for-joint-meeting-on-june-15/articleshow/92146582.cms\",\n \"content\": \"With the Rajya Sabha results exposing dissension and lack of cohesion among opposition parties, West Bengal chief minister Mamata Banerjee on Saturday reached out to her counterparts and other leaders to participate in a meeting in Delhi on June 15 to discuss the upcoming presidential polls, which are scheduled for July 18.\",\n \"non_media_links\": [\n {\n \"href\": \"https://timesofindia.indiatimes.com/india/presidential-polls-mamata-invites-22-oppn-cms-leaders-for-joint-meeting-on-june-15/articleshow/92146582.cms\",\n \"link_type\": \"link\"\n }\n ],\n \"media_links\": []\n}"
100101
]
101102
}
102103
```

Narek Arsenyan/rss_reader_package/cache_worker.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ def store_feed_in_cache(feed: Feed):
2727
feed: Feed object with all necessary data
2828
"""
2929

30-
print("here")
3130
date = str(datetime.strptime(feed.date, "%a, %d %b %Y %H:%M:%S %z").date())
32-
print("here 2")
3331
source = feed.source_url
3432
feed_id = feed.link
3533
config.verbose_print("Getting user cache directory", "bold")

Narek Arsenyan/rss_reader_package/feed_fetcher.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,5 @@ def fetch_feeds(self):
7171
formatted_feed = Feed(source_title, self.__source, title, date, link, raw_content, feed_links, media_links)
7272
CacheWorker.store_feed_in_cache(formatted_feed)
7373
self.feeds_formatted.append(formatted_feed)
74-
with open("content.txt", "w") as f:
75-
f.write(str(items))
7674
except Exception:
7775
raise WrongUrlError("Specified url is not rss type")

Narek Arsenyan/rss_reader_package/tests/test_feed.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,24 @@ class TestFeed(unittest.TestCase):
77
parsed_feed = Feed.json_to_feed(mock_feed_raw)
88

99
def test_process_feed(self):
10-
self.assertIsNone(TestFeed.parsed_feed.source_title)
11-
self.assertEqual(TestFeed.parsed_feed.title, "Taiwanese F-16 fighter makes emergency landing in Hawaii")
12-
self.assertEqual(TestFeed.parsed_feed.date, "2022-06-07T19:16:43Z")
10+
self.assertEqual(TestFeed.parsed_feed.source_title, "The Daily")
11+
self.assertEqual(TestFeed.parsed_feed.title, "Why Is It So Hard to Buy a House in America Right Now?")
12+
self.assertEqual(TestFeed.parsed_feed.date, "Tue, 21 Jun 2022 09:50:00 +0000")
1313
self.assertEqual(TestFeed.parsed_feed.link,
14-
"https://news.yahoo.com/taiwanese-f-16-fighter-makes-191643064.html")
15-
self.assertIsNone(TestFeed.parsed_feed.content)
16-
self.assertEqual(len(TestFeed.parsed_feed.non_media_links), 0)
14+
"https://www.nytimes.com/the-daily")
15+
self.assertEqual(len(TestFeed.parsed_feed.content), 1139)
16+
self.assertEqual(len(TestFeed.parsed_feed.non_media_links), 3)
1717
self.assertEqual(TestFeed.parsed_feed.media_links[0].href,
18-
"https://s.yimg.com/uu/api/res/1.2/xEduvF_K_md_I0S4N_bKPA--~B/"
19-
"aD0zMzMzO3c9NTAwMDthcHBpZD15dGFjaHlvbg--/"
20-
"https://media.zenfs.com/en/ap.org/d6b6186493eecb5a8085e62472973496")
18+
"https://dts.podtrac.com/redirect.mp3/chrt.fm/track/8DB4DB/pdst.fm/e/nyt.simplecastaudio.com/"
19+
"03d8b493-87fc-4bd1-931f-8a8e9b945d8a/episodes/230797bf-6d47-4648-81b5-79750b8d8023/audio/"
20+
"128/default.mp3?aid=rss_feed&awCollectionId=03d8b493-87fc-4bd1-931f-8a8e9b945d8a&awEpisodeId="
21+
"230797bf-6d47-4648-81b5-79750b8d8023&feed=54nAGcIl")
2122

2223
def test_to_json(self):
2324
self.assertEqual(type(TestFeed.parsed_feed.to_json()), str)
24-
self.assertEqual(len(TestFeed.parsed_feed.to_json()), 540)
2525

2626
def test_to_readable(self):
2727
self.assertEqual(type(TestFeed.parsed_feed.to_json()), str)
28-
self.assertEqual(len(TestFeed.parsed_feed.to_json()), 374)
2928

3029

3130
unittest.main()

0 commit comments

Comments
 (0)