Ejemplo n.º 1
0
 def test_parse_overview(self):
     fmt = nntplib._DEFAULT_OVERVIEW_FMT + ["xref"]
     # First example from RFC 3977
     lines = [
         '3000234\tI am just a test article\t"Demo User" '
         '<*****@*****.**>\t6 Oct 1998 04:38:40 -0500\t'
         '<*****@*****.**>\t<*****@*****.**>\t1234\t'
         '17\tXref: news.example.com misc.test:3000363',
     ]
     overview = nntplib._parse_overview(lines, fmt)
     (art_num, fields), = overview
     self.assertEqual(art_num, 3000234)
     self.assertEqual(
         fields, {
             'subject': 'I am just a test article',
             'from': '"Demo User" <*****@*****.**>',
             'date': '6 Oct 1998 04:38:40 -0500',
             'message-id': '<*****@*****.**>',
             'references': '<*****@*****.**>',
             ':bytes': '1234',
             ':lines': '17',
             'xref': 'news.example.com misc.test:3000363',
         })
     # Second example; here the "Xref" field is totally absent (including
     # the header name) and comes out as None
     lines = [
         '3000234\tI am just a test article\t"Demo User" '
         '<*****@*****.**>\t6 Oct 1998 04:38:40 -0500\t'
         '<*****@*****.**>\t<*****@*****.**>\t1234\t'
         '17\t\t',
     ]
     overview = nntplib._parse_overview(lines, fmt)
     (art_num, fields), = overview
     self.assertEqual(fields['xref'], None)
     # Third example; the "Xref" is an empty string, while "references"
     # is a single space.
     lines = [
         '3000234\tI am just a test article\t"Demo User" '
         '<*****@*****.**>\t6 Oct 1998 04:38:40 -0500\t'
         '<*****@*****.**>\t \t1234\t'
         '17\tXref: \t',
     ]
     overview = nntplib._parse_overview(lines, fmt)
     (art_num, fields), = overview
     self.assertEqual(fields['references'], ' ')
     self.assertEqual(fields['xref'], '')
Ejemplo n.º 2
0
 def test_parse_overview(self):
     fmt = nntplib._DEFAULT_OVERVIEW_FMT + ["xref"]
     # First example from RFC 3977
     lines = [
         '3000234\tI am just a test article\t"Demo User" '
         '<*****@*****.**>\t6 Oct 1998 04:38:40 -0500\t'
         '<*****@*****.**>\t<*****@*****.**>\t1234\t'
         '17\tXref: news.example.com misc.test:3000363',
     ]
     overview = nntplib._parse_overview(lines, fmt)
     (art_num, fields), = overview
     self.assertEqual(art_num, 3000234)
     self.assertEqual(fields, {
         'subject': 'I am just a test article',
         'from': '"Demo User" <*****@*****.**>',
         'date': '6 Oct 1998 04:38:40 -0500',
         'message-id': '<*****@*****.**>',
         'references': '<*****@*****.**>',
         ':bytes': '1234',
         ':lines': '17',
         'xref': 'news.example.com misc.test:3000363',
     })
     # Second example; here the "Xref" field is totally absent (including
     # the header name) and comes out as None
     lines = [
         '3000234\tI am just a test article\t"Demo User" '
         '<*****@*****.**>\t6 Oct 1998 04:38:40 -0500\t'
         '<*****@*****.**>\t<*****@*****.**>\t1234\t'
         '17\t\t',
     ]
     overview = nntplib._parse_overview(lines, fmt)
     (art_num, fields), = overview
     self.assertEqual(fields['xref'], None)
     # Third example; the "Xref" is an empty string, while "references"
     # is a single space.
     lines = [
         '3000234\tI am just a test article\t"Demo User" '
         '<*****@*****.**>\t6 Oct 1998 04:38:40 -0500\t'
         '<*****@*****.**>\t \t1234\t'
         '17\tXref: \t',
     ]
     overview = nntplib._parse_overview(lines, fmt)
     (art_num, fields), = overview
     self.assertEqual(fields['references'], ' ')
     self.assertEqual(fields['xref'], '')
Ejemplo n.º 3
0
 def update_event(self, inp=-1):
     self.set_output_val(0, nntplib._parse_overview(self.input(0), self.input(1), self.input(2)))