Add tests for feedgen:main
This patch adds some tests for the main routine of feedgen. Signed-off-by: Lars Kiesow <lkiesow@uos.de>
This commit is contained in:
parent
fee00f3337
commit
c633fd4d64
2 changed files with 45 additions and 1 deletions
|
@ -44,7 +44,7 @@ def print_enc(s):
|
||||||
print(s)
|
print(s)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def main():
|
||||||
if len(sys.argv) != 2 or not (
|
if len(sys.argv) != 2 or not (
|
||||||
sys.argv[1].endswith('rss') or
|
sys.argv[1].endswith('rss') or
|
||||||
sys.argv[1].endswith('atom') or
|
sys.argv[1].endswith('atom') or
|
||||||
|
@ -138,3 +138,7 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
elif arg.endswith('rss'):
|
elif arg.endswith('rss'):
|
||||||
fg.rss_file(arg)
|
fg.rss_file(arg)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
40
tests/test_main.py
Normal file
40
tests/test_main.py
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
'''
|
||||||
|
Tests for feedgen main
|
||||||
|
'''
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
import unittest
|
||||||
|
from feedgen import __main__
|
||||||
|
|
||||||
|
|
||||||
|
class TestSequenceFunctions(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_usage(self):
|
||||||
|
sys.argv = ['feedgen']
|
||||||
|
try:
|
||||||
|
__main__.main()
|
||||||
|
except BaseException as e:
|
||||||
|
assert e.code is None
|
||||||
|
|
||||||
|
def test_feed(self):
|
||||||
|
for ftype in 'rss', 'atom', 'podcast', 'torrent', 'dc.rss', 'dc.atom',\
|
||||||
|
'syndication.rss', 'syndication.atom':
|
||||||
|
sys.argv = ['feedgen', ftype]
|
||||||
|
try:
|
||||||
|
__main__.main()
|
||||||
|
except:
|
||||||
|
assert False
|
||||||
|
|
||||||
|
def test_file(self):
|
||||||
|
for extemsion in '.atom', '.rss':
|
||||||
|
_, filename = tempfile.mkstemp(extemsion)
|
||||||
|
sys.argv = ['feedgen', filename]
|
||||||
|
try:
|
||||||
|
__main__.main()
|
||||||
|
except:
|
||||||
|
assert False
|
||||||
|
os.remove(filename)
|
Loading…
Reference in a new issue