Example #1
0
 def article(self, art_num):
     if art_num not in (1, 2, 3):
         raise nntplib.NNTPTemporaryError('Bad call to article')
     if art_num == 2 and fail == 2:
         raise nntplib.NNTPTemporaryError('Bad call to article')
     lines = make_header(art_num)
     lines.extend([b'', b'This is the message body'])
     info.number = art_num
     info.message_id = '<msg{}@example.com'.format(art_num),
     info.lines = lines
     return ('', info)
Example #2
0
 def head(self, art_num):
     if art_num not in (1, 2, 3):
         raise nntplib.NNTPTemporaryError('Bad call to head')
     lines = make_header(art_num)
     info.number = art_num
     info.message_id = '<msg{}@example.com'.format(art_num),
     info.lines = lines
     return ('', info)
Example #3
0
 def get_resp(self):
     line = self.get_line()
     code = line.split(None, 1)[0]
     log.debug(line.strip())
     if code.startswith('4'):
         raise nntplib.NNTPTemporaryError(line)
     if code.startswith('5'):
         raise nntplib.NNTPPermanentError(line)
     return code, line
Example #4
0
    def article(self, article_id):
        a = self.__articles[article_id]
        message_id = a[0]

        if message_id == 'error':
            raise nntplib.NNTPTemporaryError('not found')

        with open(a[1], 'rb') as f:
            lines = [l.rstrip() for l in f]
        return None, MockArticleInfo(article_id, message_id, lines)
Example #5
0
 def group(self, group_name):
     if group_name == 'my.group':
         return ('', 3, 1, 3, group_name)
     else:
         raise nntplib.NNTPTemporaryError(
             'No such group: {}'.format(group_name))