aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2023-05-25 20:29:03 +0200
committerMatěj Cepl <mcepl@cepl.eu>2023-05-25 23:34:44 +0200
commit12cd578201bffe69c3f4d88081d8698d0c79d23f (patch)
tree971e52bd2d81f6962ccf0da9c2711c97b195997a /test
parent4e2bdb32cb61490e600b51b67a1dcfd7b1c683e1 (diff)
downloadpygn-12cd578201bffe69c3f4d88081d8698d0c79d23f.tar.gz
Partially revert d5fc1faf927a ... reintroduce main() interface.0.11.0
Fixes: https://todo.sr.ht/~mcepl/pygn/8
Diffstat (limited to 'test')
-rwxr-xr-x[-rw-r--r--]test/test_pyg.py50
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)