test_multi.py (829B)
1 # standard imports 2 import os 3 import unittest 4 import tempfile 5 import logging 6 import uuid 7 import shutil 8 9 # local imports 10 from feedwarrior.entry import to_multipart_file 11 from feedwarrior.entry import from_multipart_file 12 13 logging.basicConfig(level=logging.DEBUG) 14 logg = logging.getLogger() 15 16 17 class TestMultipart(unittest.TestCase): 18 19 def setUp(self): 20 uu = uuid.uuid4() 21 self.feed_uuid = uu 22 self.path = tempfile.mkdtemp() 23 24 25 def tearDown(self): 26 shutil.rmtree(self.path) 27 28 29 def test_plain_file(self): 30 fp = os.path.join(self.path, 'plain.txt') 31 f = open(fp, 'w') 32 f.write("foo\nis bar\n") 33 f.close() 34 35 fp_multi = to_multipart_file(fp) 36 37 o = from_multipart_file(fp_multi) 38 print(o.serialize()) 39 40 41 if __name__ == '__main__': 42 unittest.main()