Ejemplo n.º 1
0
    def test_data_feed_created_with_descending_sort_order_from_options(self):
        options_with_descending_order = {
            "url": self._VALID_URL,
            "sort": "oldest"
        }

        data_feed = RssFeedCreator().create(options_with_descending_order,
                                            self._EMPTY_SECRET_STORE)
        self.assertEqual("oldest", data_feed.get_sort_order())
Ejemplo n.º 2
0
    def test_data_feed_created_with_url_from_options(self):
        options_with_url = {"url": "https://sketchingdev.co.uk/feed.xml"}

        data_feed = RssFeedCreator().create(options_with_url,
                                            self._EMPTY_SECRET_STORE)

        self.assertIsInstance(data_feed, RssFeed)
Ejemplo n.º 3
0
    def test_exception_raised_when_no_url_in_options(self):
        with pytest.raises(MissingRequiredOptionException) as err_info:
            RssFeedCreator().create(self._EMPTY_OPTIONS,
                                    self._EMPTY_SECRET_STORE)

        self.assertEqual("Expected 'url' option to exist",
                         err_info.value.message)
Ejemplo n.º 4
0
    def test_messages_sorted_natural_order_by_default(self):
        self.http_server.serve_content(TestFeed._RSS_FEED)
        options = {"url": self.http_server.url}

        data_feed = RssFeedCreator().create(options, self._EMPTY_SECRET_STORE)
        messages = data_feed.get_messages()

        self.assertEqual(3, len(messages))
        self.assertEqual(
            "Dummy Item 1\nhttps://item/1\n2018-01-01T00:00:00+00:00",
            messages[0].text)
        self.assertEqual(
            "Dummy Item 2\nhttps://item/2\n2018-01-03T00:00:00+00:00",
            messages[1].text)
        self.assertEqual(
            "Dummy Item 3\nhttps://item/3\n2018-01-02T00:00:00+00:00",
            messages[2].text)
Ejemplo n.º 5
0
    def test_exception_raised_when_invalid_sort_in_options(self):
        options_with_invalid_sort = {"url": self._VALID_URL, "sort": "invalid"}

        with pytest.raises(MissingRequiredOptionException) as err_info:
            RssFeedCreator().create(options_with_invalid_sort,
                                    self._EMPTY_SECRET_STORE)

        self.assertEqual(
            "Sorting value for RSS feed can only be either ascending or descending",
            err_info.value.message)
Ejemplo n.º 6
0
 def test_id_is_rss(self):
     self.assertEqual("rss", RssFeedCreator.get_id())