2005-12-07 21:55:16 +00:00
|
|
|
|
# -*- coding: iso-8859-1 -*-
|
2014-03-02 06:45:04 +00:00
|
|
|
|
# Copyright (C) 2004-2010,2014 Bastian Kleineidam
|
2005-12-07 21:55:16 +00:00
|
|
|
|
#
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
|
#
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
|
#
|
2009-07-24 21:58:20 +00:00
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2005-12-07 21:55:16 +00:00
|
|
|
|
"""
|
|
|
|
|
|
Test news checking.
|
|
|
|
|
|
"""
|
2014-03-10 17:23:44 +00:00
|
|
|
|
import pytest
|
2010-02-22 07:02:19 +00:00
|
|
|
|
from tests import need_newsserver, limit_time
|
2008-05-20 17:01:16 +00:00
|
|
|
|
from . import LinkCheckTest
|
2005-12-07 21:55:16 +00:00
|
|
|
|
|
2009-06-26 05:22:05 +00:00
|
|
|
|
# Changes often, as servers tend to get invalid. Thus it is necessary
|
|
|
|
|
|
# to enable the has_newsserver() resource manually.
|
2010-11-06 16:27:23 +00:00
|
|
|
|
NNTP_SERVER = "news.uni-stuttgart.de"
|
2009-03-06 19:57:35 +00:00
|
|
|
|
# info string returned by news server
|
2014-03-02 06:45:04 +00:00
|
|
|
|
NNTP_INFO = u"200 news.uni-stuttgart.de InterNetNews NNRP server " \
|
|
|
|
|
|
u"INN 2.5.2 ready (no posting)"
|
2009-06-26 05:22:05 +00:00
|
|
|
|
# Most free NNTP servers are slow, so don't waist a lot of time running those.
|
2010-11-06 16:27:23 +00:00
|
|
|
|
NNTP_TIMEOUT_SECS = 30
|
2005-12-07 21:55:16 +00:00
|
|
|
|
|
2010-12-19 16:15:09 +00:00
|
|
|
|
# disabled for now until some stable news server comes up
|
2014-03-10 17:23:44 +00:00
|
|
|
|
@pytest.mark.skipif("True")
|
|
|
|
|
|
class TestNews (LinkCheckTest):
|
2009-06-26 05:22:05 +00:00
|
|
|
|
"""Test nntp: and news: link checking."""
|
2005-12-07 21:55:16 +00:00
|
|
|
|
|
|
|
|
|
|
def newstest (self, url, resultlines):
|
2006-08-21 20:50:10 +00:00
|
|
|
|
self.direct(url, resultlines)
|
2005-12-07 21:55:16 +00:00
|
|
|
|
|
2009-03-07 09:15:38 +00:00
|
|
|
|
def test_news_without_host (self):
|
2005-12-07 21:55:16 +00:00
|
|
|
|
# news testing
|
|
|
|
|
|
url = u"news:comp.os.linux.misc"
|
|
|
|
|
|
resultlines = [
|
|
|
|
|
|
u"url %s" % url,
|
|
|
|
|
|
u"cache key %s" % url,
|
|
|
|
|
|
u"real url %s" % url,
|
|
|
|
|
|
u"warning No NNTP server was specified, skipping this URL.",
|
|
|
|
|
|
u"valid",
|
|
|
|
|
|
]
|
|
|
|
|
|
self.newstest(url, resultlines)
|
|
|
|
|
|
# no group
|
|
|
|
|
|
url = u"news:"
|
|
|
|
|
|
resultlines = [
|
|
|
|
|
|
u"url %s" % url,
|
|
|
|
|
|
u"cache key %s" % url,
|
|
|
|
|
|
u"real url %s" % url,
|
|
|
|
|
|
u"warning No NNTP server was specified, skipping this URL.",
|
|
|
|
|
|
u"valid",
|
|
|
|
|
|
]
|
|
|
|
|
|
self.newstest(url, resultlines)
|
|
|
|
|
|
|
2009-03-07 09:15:38 +00:00
|
|
|
|
def test_snews_with_group (self):
|
2005-12-07 21:55:16 +00:00
|
|
|
|
url = u"snews:de.comp.os.unix.linux.misc"
|
|
|
|
|
|
nurl = self.norm(url)
|
|
|
|
|
|
resultlines = [
|
|
|
|
|
|
u"url %s" % url,
|
|
|
|
|
|
u"cache key %s" % nurl,
|
|
|
|
|
|
u"real url %s" % nurl,
|
|
|
|
|
|
u"warning No NNTP server was specified, skipping this URL.",
|
|
|
|
|
|
u"valid",
|
|
|
|
|
|
]
|
|
|
|
|
|
self.newstest(url, resultlines)
|
|
|
|
|
|
|
2009-03-07 09:15:38 +00:00
|
|
|
|
def test_illegal_syntax (self):
|
2005-12-07 21:55:16 +00:00
|
|
|
|
# illegal syntax
|
|
|
|
|
|
url = u"news:<3A>$%&/<2F>`(<28>%"
|
|
|
|
|
|
qurl = self.norm(url)
|
|
|
|
|
|
resultlines = [
|
|
|
|
|
|
u"url %s" % url,
|
|
|
|
|
|
u"cache key %s" % qurl,
|
|
|
|
|
|
u"real url %s" % qurl,
|
|
|
|
|
|
u"warning No NNTP server was specified, skipping this URL.",
|
|
|
|
|
|
u"valid",
|
|
|
|
|
|
]
|
|
|
|
|
|
self.newstest(url, resultlines)
|
|
|
|
|
|
|
2010-03-05 11:49:54 +00:00
|
|
|
|
@need_newsserver(NNTP_SERVER)
|
2009-03-07 14:00:02 +00:00
|
|
|
|
@limit_time(NNTP_TIMEOUT_SECS, skip=True)
|
2009-03-07 09:15:38 +00:00
|
|
|
|
def test_nntp_with_host (self):
|
2009-01-10 14:11:35 +00:00
|
|
|
|
url = u"nntp://%s/comp.lang.python" % NNTP_SERVER
|
2005-12-07 21:55:16 +00:00
|
|
|
|
resultlines = [
|
|
|
|
|
|
u"url %s" % url,
|
|
|
|
|
|
u"cache key %s" % url,
|
|
|
|
|
|
u"real url %s" % url,
|
2009-03-06 19:57:35 +00:00
|
|
|
|
u"info %s" % NNTP_INFO,
|
2005-12-07 21:55:16 +00:00
|
|
|
|
u"info News group comp.lang.python found.",
|
|
|
|
|
|
u"valid",
|
|
|
|
|
|
]
|
|
|
|
|
|
self.newstest(url, resultlines)
|
|
|
|
|
|
|
2010-03-05 11:49:54 +00:00
|
|
|
|
@need_newsserver(NNTP_SERVER)
|
2009-03-07 14:00:02 +00:00
|
|
|
|
@limit_time(NNTP_TIMEOUT_SECS, skip=True)
|
2005-12-07 21:55:16 +00:00
|
|
|
|
def test_article_span (self):
|
2009-01-10 14:11:35 +00:00
|
|
|
|
url = u"nntp://%s/comp.lang.python/1-5" % NNTP_SERVER
|
2005-12-07 21:55:16 +00:00
|
|
|
|
resultlines = [
|
|
|
|
|
|
u"url %s" % url,
|
|
|
|
|
|
u"cache key %s" % url,
|
|
|
|
|
|
u"real url %s" % url,
|
2009-03-06 19:57:35 +00:00
|
|
|
|
u"info %s" % NNTP_INFO,
|
2005-12-07 21:55:16 +00:00
|
|
|
|
u"info News group comp.lang.python found.",
|
|
|
|
|
|
u"valid",
|
|
|
|
|
|
]
|
|
|
|
|
|
self.newstest(url, resultlines)
|
2009-03-07 09:15:38 +00:00
|
|
|
|
|
|
|
|
|
|
def test_article_span_no_host (self):
|
2005-12-07 21:55:16 +00:00
|
|
|
|
url = u"news:comp.lang.python/1-5"
|
|
|
|
|
|
resultlines = [
|
|
|
|
|
|
u"url %s" % url,
|
|
|
|
|
|
u"cache key %s" % url,
|
|
|
|
|
|
u"real url %s" % url,
|
|
|
|
|
|
u"warning No NNTP server was specified, skipping this URL.",
|
|
|
|
|
|
u"valid",
|
|
|
|
|
|
]
|
|
|
|
|
|
self.newstest(url, resultlines)
|
|
|
|
|
|
|
2010-03-05 11:49:54 +00:00
|
|
|
|
@need_newsserver(NNTP_SERVER)
|
2009-03-07 14:00:02 +00:00
|
|
|
|
@limit_time(NNTP_TIMEOUT_SECS, skip=True)
|
2005-12-07 21:55:16 +00:00
|
|
|
|
def test_host_no_group (self):
|
2009-01-10 14:11:35 +00:00
|
|
|
|
url = u"nntp://%s/" % NNTP_SERVER
|
2005-12-07 21:55:16 +00:00
|
|
|
|
resultlines = [
|
|
|
|
|
|
u"url %s" % url,
|
|
|
|
|
|
u"cache key %s" % url,
|
|
|
|
|
|
u"real url %s" % url,
|
2009-03-06 19:57:35 +00:00
|
|
|
|
u"info %s" % NNTP_INFO,
|
2005-12-07 21:55:16 +00:00
|
|
|
|
u"warning No newsgroup specified in NNTP URL.",
|
|
|
|
|
|
u"valid",
|
|
|
|
|
|
]
|
|
|
|
|
|
self.newstest(url, resultlines)
|