def test_get_news_max_items_2(self):
        feed_reader = RssNewsFeedParser()

        actual = feed_reader.get_news('music', max_items=2)

        for expected_result, actual_result in zip_longest(expected[:2], actual):
            self.assertEquals(expected_result, actual_result)
    def test_get_news_music(self):
        feed_reader = RssNewsFeedParser()

        actual = feed_reader.get_news('music')

        for expected_result, actual_result in zip_longest(expected, actual):
            self.assertEquals(expected_result, actual_result)
def test_parse_content_max_items_2():
    feed_parser = RssNewsFeedParser()

    actual = feed_parser.parse_xml_content(parse_content_input, max_items=2)

    for expected_result, actual_result in zip_longest(expected[:2], actual):
        assert expected_result == actual_result
def test_get_news_music_max_items_1():
    feed_reader = RssNewsFeedParser()

    actual = feed_reader.get_news('music', max_items=1)

    assert 1 == len(actual)
    assert expected[0] == actual[0]
def test_get_news_max_items_2():
    feed_parser = RssNewsFeedParser()

    actual = feed_parser.get_news('music', max_items=2)

    for expected_result, actual_result in zip_longest(expected[:2], actual):
        assert expected_result == actual_result
def test_get_news_music():
    feed_parser = RssNewsFeedParser()

    actual = feed_parser.get_news('music')

    for expected_result, actual_result in zip_longest(expected, actual):
        assert expected_result == actual_result
Exemplo n.º 7
0
def test_get_news_music():
    feed_parser = RssNewsFeedParser()

    actual = feed_parser.get_news('music')

    for expected_result, actual_result in zip_longest(expected, actual):
        assert expected_result == actual_result
Exemplo n.º 8
0
def test_get_news_max_items_2():
    feed_parser = RssNewsFeedParser()

    actual = feed_parser.get_news('music', max_items=2)

    for expected_result, actual_result in zip_longest(expected[:2], actual):
        assert expected_result == actual_result
Exemplo n.º 9
0
    def test_get_news_max_items_2(self):
        feed_reader = RssNewsFeedParser()

        actual = feed_reader.get_news('music', max_items=2)

        for expected_result, actual_result in zip_longest(expected[:2], actual):
            self.assertEquals(expected_result, actual_result)
Exemplo n.º 10
0
def test_parse_content_max_items_2():
    feed_parser = RssNewsFeedParser()

    actual = feed_parser.parse_xml_content(parse_content_input, max_items=2)

    for expected_result, actual_result in zip_longest(expected[:2], actual):
        assert expected_result == actual_result
Exemplo n.º 11
0
    def test_parse_content_max_items_2(self):
        feed_reader = RssNewsFeedParser()

        actual = feed_reader.parse_xml_content(xml_input, max_items=2)

        for expected_result, actual_result in zip_longest(expected[:2], actual):
            self.assertEquals(expected_result, actual_result)
Exemplo n.º 12
0
    def test_parse_content_max_items_2(self):
        feed_reader = RssNewsFeedParser()

        actual = feed_reader.parse_xml_content(xml_input, max_items=2)

        for expected_result, actual_result in zip_longest(expected[:2], actual):
            self.assertEquals(expected_result, actual_result)
def test_get_news_music_max_items_1():
    feed_reader = RssNewsFeedParser()

    actual = feed_reader.get_news('music', max_items=1)

    assert 1 == len(actual)
    assert expected[0] == actual[0]
Exemplo n.º 14
0
    def test_get_news_music(self):
        feed_reader = RssNewsFeedParser()

        actual = feed_reader.get_news('music')

        for expected_result, actual_result in zip_longest(expected, actual):
            self.assertEquals(expected_result, actual_result)
Exemplo n.º 15
0
    def test_parse_content(self):
        feed_reader = RssNewsFeedParser()

        actual = feed_reader.parse_xml_content(xml_input)

        # By using itertools.zip_longest(), assertEquals() will eventually fail
        # if the lists are not the same length
        for expected_result, actual_result in zip_longest(expected, actual):
            self.assertEquals(expected_result, actual_result)
Exemplo n.º 16
0
    def test_get_news_max_items_1(self):
        feed_reader = RssNewsFeedParser()

        # Note the call FeedReader.get_news() with a max_items argument
        actual = feed_reader.get_news('music', max_items=1)

        # Note the use of list slicing in the following assertion to verify
        # that the actual returned list contains only one item.
        self.assertEqual(expected[:1], actual)
Exemplo n.º 17
0
    def test_get_news_max_items_1(self):
        feed_reader = RssNewsFeedParser()

        # Note the call FeedReader.get_news() with a max_items argument
        actual = feed_reader.get_news('music', max_items=1)

        # Note the use of list slicing in the following assertion to verify
        # that the actual returned list contains only one item.
        self.assertEqual(expected[:1], actual)
Exemplo n.º 18
0
    def test_parse_content(self):
        feed_reader = RssNewsFeedParser()

        actual = feed_reader.parse_xml_content(xml_input)

        # By using itertools.zip_longest(), assertEquals() will eventually fail
        # if the lists are not the same length
        for expected_result, actual_result in zip_longest(expected, actual):
            self.assertEquals(expected_result, actual_result)
Exemplo n.º 19
0
    def test_get_news_invalid_news_type(self):
        # TODO: in the test_get_news_invalid_news_type method, create an
        # instance of RssNewsFeedParser and save a reference to it in a
        # local variable.
        feed_reader = RssNewsFeedParser()

        # TODO: Call an assert method to verify that if you call the
        # feed reader's get_news() method with an invalid news type argument
        # (for example, 'pluto'), the method raises a FeedReaderException.
        with self.assertRaises(FeedReaderException):
            feed_reader.get_news('pluto')
Exemplo n.º 20
0
    def test_parse_content_items_missing(self):
        feed_reader = RssNewsFeedParser()

        minimal_input = "<rss><item></item></rss>"
        minimal_results = [
            {"title": "", "link": "", "date_time": "", "image_thumbnail": "", "image_banner": "", "content": ""}
        ]

        actual_results = feed_reader.parse_xml_content(minimal_input)

        self.assertEquals(minimal_results, actual_results)
Exemplo n.º 21
0
    def test_get_news_invalid_news_type(self):
        # TODO: in the test_get_news_invalid_news_type method, create an
        # instance of RssNewsFeedParser and save a reference to it in a
        # local variable.
        feed_reader = RssNewsFeedParser()

        # TODO: Call an assert method to verify that if you call the
        # feed reader's get_news() method with an invalid news type argument
        # (for example, 'pluto'), the method raises a FeedReaderException.
        with self.assertRaises(FeedReaderException):
            feed_reader.get_news('pluto')
Exemplo n.º 22
0
    def test_get_news_music(self):
        # TODO: in the test_get_news_music method, create an instance of
        # RssNewsFeedParser and save a reference to it in a local variable
        feed_reader = RssNewsFeedParser()

        # TODO:
        # 1. call the feed reader's get_news() method, passing 'music' as the
        #    argument
        # 2. save the list returned by the method in a local variable
        #    named `actual`
        actual = feed_reader.get_news('music')

        # TODO: call a method that asserts the list named `expected` is
        # equal to the list named `actual`
        self.assertEqual(expected, actual)
Exemplo n.º 23
0
    def test_get_news_music(self):
        # TODO: in the test_get_news_music method, create an instance of
        # RssNewsFeedParser and save a reference to it in a local variable
        feed_reader = RssNewsFeedParser()

        # TODO:
        # 1. call the feed reader's get_news() method, passing 'music' as the
        #    argument
        # 2. save the list returned by the method in a local variable
        #    named `actual`
        actual = feed_reader.get_news('music')

        # TODO: call a method that asserts the list named `expected` is
        # equal to the list named `actual`
        self.assertEqual(expected, actual)
Exemplo n.º 24
0
def test_parse_content_items_missing():
    feed_reader = RssNewsFeedParser()

    minimal_input = '<rss><item></item></rss>'
    minimal_results = [{
        'title': '',
        'link': '',
        'date_time': '',
        'image_thumbnail': '',
        'image_banner': '',
        'content': ''
    }]

    actual_results = feed_reader.parse_xml_content(minimal_input)

    assert minimal_results == actual_results
Exemplo n.º 25
0
    def test_parse_content_items_missing(self):
        """This test case will boost test coverage to 100%"""

        feed_reader = RssNewsFeedParser()

        minimal_input = '<rss><item></item></rss>'
        minimal_results = [{
            'title': '',
            'link': '',
            'date_time': '',
            'image_thumbnail': '',
            'image_banner': '',
            'content': ''
        }]

        actual_results = feed_reader.parse_xml_content(minimal_input)

        self.assertEqual(minimal_results, actual_results)
Exemplo n.º 26
0
    def test_get_news_music_max_items_1(self):
        # TODO: in the test_get_news_music_max_items_1 method, create an
        # instance of RssNewsFeedParser and save a reference to it in a
        # local variable.
        feed_reader = RssNewsFeedParser()

        # TODO:
        # 1. call the feed reader's get_news() method, passing
        #    news_type='music' and max_items=1 as the arguments.
        # 2. save the list returned by the method in a local variable
        actual = feed_reader.get_news('music', max_items=1)

        # TODO: call a method that asserts the returned list has length 1
        self.assertEqual(1, len(actual))

        # TODO: verify that the first item of the `expected` list equals the 
        # first item of the returned list.
        self.assertEqual(expected[0], actual[0])
Exemplo n.º 27
0
    def test_get_news_music_max_items_1(self):
        # TODO: in the test_get_news_music_max_items_1 method, create an
        # instance of RssNewsFeedParser and save a reference to it in a
        # local variable.
        feed_reader = RssNewsFeedParser()

        # TODO:
        # 1. call the feed reader's get_news() method, passing
        #    news_type='music' and max_items=1 as the arguments.
        # 2. save the list returned by the method in a local variable
        actual = feed_reader.get_news('music', max_items=1)

        # TODO: call a method that asserts the returned list has length 1
        self.assertEqual(1, len(actual))

        # TODO: verify that the first item of the `expected` list equals the
        # first item of the returned list.
        self.assertEqual(expected[0], actual[0])
def test_parse_content_items_missing():
    feed_reader = RssNewsFeedParser()

    minimal_input = '<rss><item></item></rss>'
    minimal_results = [
        {
            'title': '',
            'link': '',
            'date_time': '',
            'image_thumbnail': '',
            'image_banner': '',
            'content': ''
        }
    ]

    actual_results = feed_reader.parse_xml_content(minimal_input)

    assert minimal_results == actual_results
Exemplo n.º 29
0
    def test_parse_content_items_missing(self):
        feed_reader = RssNewsFeedParser()

        minimal_input = '<rss><item></item></rss>'
        minimal_results = [{
            'title': '',
            'link': '',
            'date_time': '',
            'image_thumbnail': '',
            'image_banner': '',
            'content': ''
        }]

        actual = feed_reader.parse_xml_content(minimal_input)

        for expected_result, actual_result in zip_longest(
                minimal_results, actual):
            self.assertEquals(expected_result, actual_result)
Exemplo n.º 30
0
    def test_parse_content_items_missing(self):
        feed_reader = RssNewsFeedParser()

        minimal_input = '<rss><item></item></rss>'
        minimal_results = [
            {
                'title': '',
                'link': '',
                'date_time': '',
                'image_thumbnail': '',
                'image_banner': '',
                'content': ''
            }
        ]

        actual = feed_reader.parse_xml_content(minimal_input)

        for expected_result, actual_result in zip_longest(minimal_results,
                                                          actual):
            self.assertEquals(expected_result, actual_result)
Exemplo n.º 31
0
    def test_parse_content_items_missing(self):
        """This test case will boost test coverage to 100%"""

        feed_reader = RssNewsFeedParser()

        minimal_input = '<rss><item></item></rss>'
        minimal_results = [
            {
                'title': '',
                'link': '',
                'date_time': '',
                'image_thumbnail': '',
                'image_banner': '',
                'content': ''
            }
        ]

        actual_results = feed_reader.parse_xml_content(minimal_input)

        self.assertEqual(minimal_results, actual_results)
def test_get_news_music():
    feed_reader = RssNewsFeedParser()

    actual = feed_reader.get_news('music')

    assert expected == actual
Exemplo n.º 33
0
    def test_parse_content_max_items_2(self):
        feed_reader = RssNewsFeedParser()

        actual = feed_reader.parse_xml_content(xml_input, max_items=2)

        self.assertEqual(expected[:2], actual)
Exemplo n.º 34
0
    def test_parse_content(self):
        feed_reader = RssNewsFeedParser()

        actual = feed_reader.parse_xml_content(xml_input)

        self.assertEqual(expected, actual)
Exemplo n.º 35
0
    def test_get_news_max_items_2(self):
        feed_reader = RssNewsFeedParser()

        actual = feed_reader.get_news('music', max_items=2)

        self.assertEqual(expected[:2], actual)
Exemplo n.º 36
0
    def test_parse_content(self):
        feed_reader = RssNewsFeedParser()

        actual = feed_reader.parse_xml_content(xml_input)

        self.assertEqual(expected, actual)
Exemplo n.º 37
0
    def test_get_news_music_zip_longest(self):
        feed_reader = RssNewsFeedParser()

        actual = feed_reader.get_news('music')

        self.assertEqual(expected, actual)
def test_get_news_invalid_news_type():
    feed_reader = RssNewsFeedParser()

    feed_reader.get_news('pluto')
Exemplo n.º 39
0
    def test_get_news_max_items_2(self):
        feed_reader = RssNewsFeedParser()

        actual = feed_reader.get_news('music', max_items=2)

        self.assertEqual(expected[:2], actual)
Exemplo n.º 40
0
def test_parse_content():
    feed_reader = RssNewsFeedParser()

    actual = feed_reader.parse_xml_content(xml_input)

    assert expected == actual
def test_get_news_music():
    feed_reader = RssNewsFeedParser()

    actual = feed_reader.get_news('music')

    assert expected == actual
def test_parse_content_max_items_2():
    feed_reader = RssNewsFeedParser()

    actual = feed_reader.parse_xml_content(xml_input, max_items=2)

    assert expected[:2] == actual
def test_parse_content():
    feed_reader = RssNewsFeedParser()

    actual = feed_reader.parse_xml_content(xml_input)

    assert expected == actual
def test_get_news_max_items_2():
    feed_reader = RssNewsFeedParser()

    actual = feed_reader.get_news('music', max_items=2)

    assert expected[:2] == actual
def test_get_news_invalid_news_type():
    feed_reader = RssNewsFeedParser()

    feed_reader.get_news('pluto')
Exemplo n.º 46
0
 def test_get_news_invalid_news_type(self):
     feed_reader = RssNewsFeedParser()
     with self.assertRaises(FeedReaderException):
         feed_reader.get_news('pluto')
Exemplo n.º 47
0
    def test_get_news_music_zip_longest(self):
        feed_reader = RssNewsFeedParser()

        actual = feed_reader.get_news('music')

        self.assertEqual(expected, actual)
Exemplo n.º 48
0
def test_parse_content_max_items_2():
    feed_reader = RssNewsFeedParser()

    actual = feed_reader.parse_xml_content(xml_input, max_items=2)

    assert expected[:2] == actual
Exemplo n.º 49
0
    def test_parse_content_max_items_2(self):
        feed_reader = RssNewsFeedParser()

        actual = feed_reader.parse_xml_content(xml_input, max_items=2)

        self.assertEqual(expected[:2], actual)
Exemplo n.º 50
0
def test_get_news_max_items_2():
    feed_reader = RssNewsFeedParser()

    actual = feed_reader.get_news('music', max_items=2)

    assert expected[:2] == actual
Exemplo n.º 51
0
 def test_get_news_invalid_news_type(self):
     feed_reader = RssNewsFeedParser()
     with self.assertRaises(FeedReaderException):
         feed_reader.get_news('pluto')