Пример #1
0
def test_item_parser_base_get_site(session):
    feed = FeedFactory()
    assert feed.title is not None
    assert feed.site_name is None

    parser = RssItemParser()
    site = parser.get_site(feed)
    assert site == feed.title

    feed.site_name = 'Test'
    site = parser.get_site(feed)
    assert site == feed.site_name

    feed.site_name = None
    feed.title = None
    site = parser.get_site(feed)
    assert site is None
Пример #2
0
    def test_valid_url(self):
        urls = [
            'http://domain.tld/entry/1',
            'http://domain.tld/entry/image_.png',
            'http://blog.superfeedr.com/',
            'www.domain.com',
            'domain.com',
            'domain.net',
            'www.domain.net',
            'https://www.domain.net',
            'http://domain.com/test'
        ]

        parser = RssItemParser()
        for url in urls:
            valid = parser.valid_url(url)
            print('Url: {0}, Result: {1}'.format(url, valid))
            self.assertIsNotNone(valid)
Пример #3
0
 def test_item_guid_from_link_and_none_id(self):
     link = 'abcde'
     item = dict(id=None, link=link)
     parser = RssItemParser(item)
     self.assertEqual(parser.item_guid(item), link)
Пример #4
0
 def test_item_guid(self):
     id = 'abcde'
     item = dict(id=id)
     parser = RssItemParser(item)
     self.assertEqual(parser.item_guid(item), id)