Skip to content

Commit

Permalink
Merge pull request #139 from moggers87/lint-fix
Browse files Browse the repository at this point in the history
Fix tests in master
  • Loading branch information
moggers87 committed May 25, 2020
2 parents 6a0345a + a7a9e42 commit b41fed0
Show file tree
Hide file tree
Showing 12 changed files with 111 additions and 120 deletions.
14 changes: 7 additions & 7 deletions docs/conf.py
Expand Up @@ -66,9 +66,9 @@
master_doc = 'index'

# General information about the project.
project = u'Salmon'
copyright = u'2015, 2017 Matt Molyneaux'
author = u'Matt Molyneaux'
project = 'Salmon'
copyright = '2015, 2017 Matt Molyneaux'
author = 'Matt Molyneaux'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -241,8 +241,8 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'Salmon.tex', u'Salmon Documentation',
u'Matt Molyneaux', 'manual'),
(master_doc, 'Salmon.tex', 'Salmon Documentation',
'Matt Molyneaux', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -271,7 +271,7 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'salmon', u'Salmon Documentation',
(master_doc, 'salmon', 'Salmon Documentation',
[author], 1)
]

Expand All @@ -285,7 +285,7 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'Salmon', u'Salmon Documentation',
(master_doc, 'Salmon', 'Salmon Documentation',
author, 'Salmon', 'One line description of project.',
'Miscellaneous'),
]
Expand Down
134 changes: 67 additions & 67 deletions salmon/bounce.py
Expand Up @@ -20,79 +20,79 @@
BOUNCE_MAX = len(BOUNCE_MATCHERS) * 2.0

PRIMARY_STATUS_CODES = {
u'1': u'Unknown Status Code 1',
u'2': u'Success',
u'3': u'Temporary Failure',
u'4': u'Persistent Transient Failure',
u'5': u'Permanent Failure'
'1': 'Unknown Status Code 1',
'2': 'Success',
'3': 'Temporary Failure',
'4': 'Persistent Transient Failure',
'5': 'Permanent Failure'
}

SECONDARY_STATUS_CODES = {
u'0': u'Other or Undefined Status',
u'1': u'Addressing Status',
u'2': u'Mailbox Status',
u'3': u'Mail System Status',
u'4': u'Network and Routing Status',
u'5': u'Mail Delivery Protocol Status',
u'6': u'Message Content or Media Status',
u'7': u'Security or Policy Status',
'0': 'Other or Undefined Status',
'1': 'Addressing Status',
'2': 'Mailbox Status',
'3': 'Mail System Status',
'4': 'Network and Routing Status',
'5': 'Mail Delivery Protocol Status',
'6': 'Message Content or Media Status',
'7': 'Security or Policy Status',
}

COMBINED_STATUS_CODES = {
u'00': u'Not Applicable',
u'10': u'Other address status',
u'11': u'Bad destination mailbox address',
u'12': u'Bad destination system address',
u'13': u'Bad destination mailbox address syntax',
u'14': u'Destination mailbox address ambiguous',
u'15': u'Destination mailbox address valid',
u'16': u'Mailbox has moved',
u'17': u'Bad sender\'s mailbox address syntax',
u'18': u'Bad sender\'s system address',

u'20': u'Other or undefined mailbox status',
u'21': u'Mailbox disabled, not accepting messages',
u'22': u'Mailbox full',
u'23': u'Message length exceeds administrative limit.',
u'24': u'Mailing list expansion problem',

u'30': u'Other or undefined mail system status',
u'31': u'Mail system full',
u'32': u'System not accepting network messages',
u'33': u'System not capable of selected features',
u'34': u'Message too big for system',

u'40': u'Other or undefined network or routing status',
u'41': u'No answer from host',
u'42': u'Bad connection',
u'43': u'Routing server failure',
u'44': u'Unable to route',
u'45': u'Network congestion',
u'46': u'Routing loop detected',
u'47': u'Delivery time expired',

u'50': u'Other or undefined protocol status',
u'51': u'Invalid command',
u'52': u'Syntax error',
u'53': u'Too many recipients',
u'54': u'Invalid command arguments',
u'55': u'Wrong protocol version',

u'60': u'Other or undefined media error',
u'61': u'Media not supported',
u'62': u'Conversion required and prohibited',
u'63': u'Conversion required but not supported',
u'64': u'Conversion with loss performed',
u'65': u'Conversion failed',

u'70': u'Other or undefined security status',
u'71': u'Delivery not authorized, message refused',
u'72': u'Mailing list expansion prohibited',
u'73': u'Security conversion required but not possible',
u'74': u'Security features not supported',
u'75': u'Cryptographic failure',
u'76': u'Cryptographic algorithm not supported',
u'77': u'Message integrity failure',
'00': 'Not Applicable',
'10': 'Other address status',
'11': 'Bad destination mailbox address',
'12': 'Bad destination system address',
'13': 'Bad destination mailbox address syntax',
'14': 'Destination mailbox address ambiguous',
'15': 'Destination mailbox address valid',
'16': 'Mailbox has moved',
'17': 'Bad sender\'s mailbox address syntax',
'18': 'Bad sender\'s system address',

'20': 'Other or undefined mailbox status',
'21': 'Mailbox disabled, not accepting messages',
'22': 'Mailbox full',
'23': 'Message length exceeds administrative limit.',
'24': 'Mailing list expansion problem',

'30': 'Other or undefined mail system status',
'31': 'Mail system full',
'32': 'System not accepting network messages',
'33': 'System not capable of selected features',
'34': 'Message too big for system',

'40': 'Other or undefined network or routing status',
'41': 'No answer from host',
'42': 'Bad connection',
'43': 'Routing server failure',
'44': 'Unable to route',
'45': 'Network congestion',
'46': 'Routing loop detected',
'47': 'Delivery time expired',

'50': 'Other or undefined protocol status',
'51': 'Invalid command',
'52': 'Syntax error',
'53': 'Too many recipients',
'54': 'Invalid command arguments',
'55': 'Wrong protocol version',

'60': 'Other or undefined media error',
'61': 'Media not supported',
'62': 'Conversion required and prohibited',
'63': 'Conversion required but not supported',
'64': 'Conversion with loss performed',
'65': 'Conversion failed',

'70': 'Other or undefined security status',
'71': 'Delivery not authorized, message refused',
'72': 'Mailing list expansion prohibited',
'73': 'Security conversion required but not possible',
'74': 'Security features not supported',
'75': 'Cryptographic failure',
'76': 'Cryptographic algorithm not supported',
'77': 'Message integrity failure',
}


Expand Down
4 changes: 2 additions & 2 deletions salmon/encoding.py
Expand Up @@ -595,7 +595,7 @@ def _parse_charset_header(data):
>>> data = '=?utf-8?q?=C5=81ukasz?= the =?utf-16?b?//492B/c?='
>>> print(list(_parse_charset_header(data)))
[u'\u0141ukasz', u' the ', u'\U0001f41f']
['\u0141ukasz', ' the ', '\U0001f41f']
"""
scanner = _scan(data)
oddness = None
Expand Down Expand Up @@ -636,4 +636,4 @@ def _parse_charset_header(data):

def properly_decode_header(header):
"""Decodes headers from their ASCII-safe representation"""
return u"".join(_parse_charset_header(header))
return "".join(_parse_charset_header(header))
2 changes: 1 addition & 1 deletion salmon/mail.py
Expand Up @@ -86,7 +86,7 @@ def __init__(self, Peer, From, To, Data):
self.bounce = None

def __repr__(self):
return "From: %r" % [self.Peer, self.From, self.To]
return "From: {}".format([self.Peer, self.From, self.To])

def all_parts(self):
"""Returns all multipart mime parts. This could be an empty list."""
Expand Down
5 changes: 0 additions & 5 deletions setup.py
Expand Up @@ -10,10 +10,6 @@
'python-daemon>2.2.0',
]

tests_require = [
'jinja2<3.0',
]

extras_require = {
"docs": [
"sphinx",
Expand All @@ -33,7 +29,6 @@
'version': versioneer.get_version(),
'cmdclass': versioneer.get_cmdclass(),
'install_requires': install_requires,
'tests_require': tests_require,
'extras_require': extras_require,
'test_suite': 'tests',
'packages': ['salmon', 'salmon.handlers'],
Expand Down
16 changes: 8 additions & 8 deletions tests/bounce_tests.py
Expand Up @@ -23,18 +23,18 @@ def test_bounce_analyzer_on_bounce(self):
assert bm.bounce
self.assertEqual(bm.bounce.score, 1.0)
assert bm.bounce.probable()
self.assertEqual(bm.bounce.primary_status, (5, u'Permanent Failure'))
self.assertEqual(bm.bounce.secondary_status, (1, u'Addressing Status'))
self.assertEqual(bm.bounce.combined_status, (11, u'Bad destination mailbox address'))
self.assertEqual(bm.bounce.primary_status, (5, 'Permanent Failure'))
self.assertEqual(bm.bounce.secondary_status, (1, 'Addressing Status'))
self.assertEqual(bm.bounce.combined_status, (11, 'Bad destination mailbox address'))

assert bm.bounce.is_hard()
self.assertEqual(bm.bounce.is_hard(), not bm.bounce.is_soft())

self.assertEqual(bm.bounce.remote_mta, u'gmail-smtp-in.l.google.com')
self.assertEqual(bm.bounce.reporting_mta, u'mail.zedshaw.com')
self.assertEqual(bm.bounce.remote_mta, 'gmail-smtp-in.l.google.com')
self.assertEqual(bm.bounce.reporting_mta, 'mail.zedshaw.com')
self.assertEqual(bm.bounce.final_recipient,
u'asdfasdfasdfasdfasdfasdfewrqertrtyrthsfgdfgadfqeadvxzvz@gmail.com')
self.assertEqual(bm.bounce.diagnostic_codes[0], u'550-5.1.1')
'asdfasdfasdfasdfasdfasdfewrqertrtyrthsfgdfgadfqeadvxzvz@gmail.com')
self.assertEqual(bm.bounce.diagnostic_codes[0], '550-5.1.1')
self.assertEqual(bm.bounce.action, 'failed')
assert 'Content-Description-Parts' in bm.bounce.headers

Expand Down Expand Up @@ -68,7 +68,7 @@ def test_bounce_to_decorator(self):
assert Router.in_state(bounce_filtered_mod.START, msg)
assert bounce_filtered_mod.HARD_RAN, "Hard bounce state didn't actually run: %r" % msg.To

msg.bounce.primary_status = (4, u'Persistent Transient Failure')
msg.bounce.primary_status = (4, 'Persistent Transient Failure')
Router.clear_states()
Router.deliver(msg)
assert Router.in_state(bounce_filtered_mod.START, msg)
Expand Down
18 changes: 9 additions & 9 deletions tests/encoding_tests.py
Expand Up @@ -33,7 +33,7 @@

class EncodingTestCase(SalmonTestCase):
def test_MailBase(self):
the_subject = u'p\xf6stal'
the_subject = 'p\xf6stal'
m = encoding.MailBase()

m['To'] = "testing@localhost"
Expand Down Expand Up @@ -120,7 +120,7 @@ def test_header_to_mime_encoding(self):
def test_mutt_badness(self):
# this is a sample of possibly the worst case Mutt can produce
idiot = '=?iso-8859-1?B?SOlhdnkgTel05WwgVW7uY/hk?=\n\t=?iso-8859-1?Q?=E9?='
should_be = u'H\xe9avy M\xe9t\xe5l Un\xeec\xf8d\xe9'
should_be = 'H\xe9avy M\xe9t\xe5l Un\xeec\xf8d\xe9'
self.assertEqual(encoding.header_from_mime_encoding(idiot), should_be)

def test_header_from_mime_encoding(self):
Expand Down Expand Up @@ -148,8 +148,8 @@ def test_to_message_from_message_with_spam(self):
else:
assert m[k].strip() == m2[k].strip(), "%s: %r != %r" % (k, m[k], m2[k])

assert not m[k].startswith(u"=?")
assert not m2[k].startswith(u"=?")
assert not m[k].startswith("=?")
assert not m2[k].startswith("=?")

# salmon adds stuff to content headers that's missing from example messages
for k in encoding.CONTENT_ENCODING_KEYS:
Expand Down Expand Up @@ -305,7 +305,7 @@ def test_content_encoding_headers_are_maintained(self):

def test_odd_content_type_with_charset(self):
mail = encoding.MailBase()
mail.body = u"p\xf6stal".encode('utf-8')
mail.body = "p\xf6stal".encode('utf-8')
mail.content_encoding['Content-Type'] = ('application/plain', {'charset': 'utf-8'})

msg = encoding.to_string(mail)
Expand All @@ -326,7 +326,7 @@ def test_to_message_encoding_error(self, mp_init):

@patch('salmon.encoding.chardet.detect')
def test_guess_encoding_and_decode_unicode_error(self, detect_mock):
data = u"testß".encode("latin-1")
data = "testß".encode("latin-1")
detect_mock.return_value = {"confidence": 0.99, "encoding": "utf-8"}
with self.assertRaises(encoding.EncodingError):
encoding.guess_encoding_and_decode("ascii", data)
Expand All @@ -340,9 +340,9 @@ def test_apply_charset_to_header_with_bad_encoding_char(self):

def test_odd_roundtrip_bug(self):
decoded_addrs = [
u'"\u0414\u0435\u043b\u043e\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0441\u0442\u0432\u043e" <daniel@specelec.com>', # noqa: E501
u'"\u8003\u53d6\u5206\u4eab" <Ernest.Beard@msa.hinet.net>',
u'"Exquisite Replica"\n\t<wolfem@barnagreatlakes.com>',
'"\u0414\u0435\u043b\u043e\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0441\u0442\u0432\u043e" <daniel@specelec.com>', # noqa: E501
'"\u8003\u53d6\u5206\u4eab" <Ernest.Beard@msa.hinet.net>',
'"Exquisite Replica"\n\t<wolfem@barnagreatlakes.com>',
]

for decoded in decoded_addrs:
Expand Down
10 changes: 5 additions & 5 deletions tests/message_tests.py
Expand Up @@ -238,19 +238,19 @@ def test_craft_from_sample(self):
assert part.get_payload(), "outmsg parts don't have payload."

def test_to_from_works(self):
msg = mail.MailRequest("fakepeer", "from@localhost", [u"<to1@localhost>", u"to2@localhost"], "")
msg = mail.MailRequest("fakepeer", "from@localhost", ["<to1@localhost>", "to2@localhost"], "")
assert '<' not in msg.To, msg.To

msg = mail.MailRequest("fakepeer", "from@localhost", [u"to1@localhost", u"to2@localhost"], "")
msg = mail.MailRequest("fakepeer", "from@localhost", ["to1@localhost", "to2@localhost"], "")
assert '<' not in msg.To, msg.To

msg = mail.MailRequest("fakepeer", "from@localhost", [u"to1@localhost", u"<to2@localhost>"], "")
msg = mail.MailRequest("fakepeer", "from@localhost", ["to1@localhost", "<to2@localhost>"], "")
assert '<' not in msg.To, msg.To

msg = mail.MailRequest("fakepeer", "from@localhost", [u"to1@localhost"], "")
msg = mail.MailRequest("fakepeer", "from@localhost", ["to1@localhost"], "")
assert '<' not in msg.To, msg.To

msg = mail.MailRequest("fakepeer", "from@localhost", [u"<to1@localhost>"], "")
msg = mail.MailRequest("fakepeer", "from@localhost", ["<to1@localhost>"], "")
assert '<' not in msg.To, msg.To

def test_decode_header_randomness(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/queue_tests.py
Expand Up @@ -7,7 +7,7 @@

from .setup_env import SalmonTestCase

BYTES_MESSAGE = u"""From: me@localhost
BYTES_MESSAGE = """From: me@localhost
To: you@localhost
Subject: bob!
Expand Down

0 comments on commit b41fed0

Please sign in to comment.