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)
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)
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
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)
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))