2017-03-13 20:57:52 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
'''
|
|
|
|
Tests for feedgen main
|
|
|
|
'''
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import tempfile
|
|
|
|
import unittest
|
2018-03-04 20:05:29 +01:00
|
|
|
|
2017-03-13 20:57:52 +01:00
|
|
|
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()
|
2018-03-04 20:10:01 +01:00
|
|
|
except Exception:
|
2017-03-13 20:57:52 +01:00
|
|
|
assert False
|
|
|
|
|
|
|
|
def test_file(self):
|
|
|
|
for extemsion in '.atom', '.rss':
|
2017-03-16 16:16:46 +01:00
|
|
|
fh, filename = tempfile.mkstemp(extemsion)
|
2017-03-13 20:57:52 +01:00
|
|
|
sys.argv = ['feedgen', filename]
|
|
|
|
try:
|
|
|
|
__main__.main()
|
2018-03-04 20:10:01 +01:00
|
|
|
except Exception:
|
2017-03-13 20:57:52 +01:00
|
|
|
assert False
|
2017-03-16 16:16:46 +01:00
|
|
|
os.close(fh)
|
2017-03-13 20:57:52 +01:00
|
|
|
os.remove(filename)
|