diff options
Diffstat (limited to 'test')
-rwxr-xr-x[-rw-r--r--] | test/test_pyg.py | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/test/test_pyg.py b/test/test_pyg.py index 6044520..6777bd2 100644..100755 --- a/test/test_pyg.py +++ b/test/test_pyg.py @@ -1,12 +1,10 @@ #!/usr/bin/python -# -*- coding: utf-8 -*- - -from __future__ import absolute_import import re import subprocess import unittest import mail2news +import news2mail @unittest.skip('not ready') @@ -26,15 +24,18 @@ X-Gateway: pyg %s %s one line test -""" % (mail2news.VERSION, mail2news.DESC) +""" % (mail2news.__version__, mail2news.__description__) def test_m2n(self): - with open('examples/mail') as in_mail: - pid = subprocess.Popen([sys.executable, 'src/mail2news.py', '-Tv', '-n', 'pyg.test'], - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - universal_newlines=True) - out, _ = pid.communicate(in_mail.read()) + # with open('examples/mail') as in_mail: + # pid = subprocess.Popen([sys.executable, + # 'src/mail2news.py', '-Tv', '-n', 'pyg.test'], + # stdin=subprocess.PIPE, + # stdout=subprocess.PIPE, + # universal_newlines=True) + # out, _ = pid.communicate(in_mail.read()) + out = mail2news.main(['-T', '-v', + '-i', 'examples/mail', '-n', 'pyg.test']) self.assertEqual(out, self.expected_output) @@ -57,26 +58,29 @@ X-Gateway: pyg %s %s X-NNTP-Posting-Host: pyg.server.tld Resent-From: sender@example.com Resent-Sender: sender@example.com -""" % (mail2news.VERSION, mail2news.DESC) +""" % (mail2news.__version__, mail2news.__description__) def test_n2m(self): - with open('examples/articletest.accepted') as in_mail: - pid = subprocess.Popen([sys.executable, 'src/news2mail.py', '-Tvt', 'test@example.com', - '-s', 'sender@example.com', - '-w', 'examples/whitelist.example'], - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - universal_newlines=True) - in_message = in_mail.read().replace('pyg@pyg.server.tld', - 'kame@inwind.it') - out, err = pid.communicate(in_message) - out = re.sub(r'^Message-Id:.*$', '', out) + # with open('examples/articletest.accepted') as in_mail: + # pid = subprocess.Popen([sys.executable, 'src/news2mail.py', '-Tvt', 'test@example.com', + # '-s', 'sender@example.com', + # '-w', 'examples/whitelist.example'], + # stdin=subprocess.PIPE, + # stdout=subprocess.PIPE, + # universal_newlines=True) + # in_message = in_mail.read().replace('pyg@pyg.server.tld', + # 'kame@inwind.it') + # out, err = pid.communicate(in_message) + out = news2mail.main(['-T', '-v', '-t', 'test@example.com', + '-s', 'sender@example.com', + '-w', 'examples/whitelist.example']) + out = re.sub(r'^Message-Id:.*$', '', out) # Not sure how to compare two email mesages (with different # times, etc.) so for now just to make sure the script doesn’t # blow up and gives some output # otherwise it would be # self.assertEqual(out, expected_output) - self.assertEqual(pid.returncode, 0) + # self.assertEqual(pid.returncode, 0) self.assertGreater(len(out), 0) |