feedwarrior

Slim, portable tooling for creating and distributing decentralized append logs
git clone git://git.defalsify.org/logwarrior.git
Info | Log | Files | Refs | README | LICENSE

test_file.py (962B)


      1 # standard imports
      2 import os
      3 import unittest
      4 import tempfile
      5 import logging
      6 import uuid
      7 import shutil
      8 from email.message import EmailMessage
      9 
     10 # local imports
     11 from feedwarrior.adapters.fileadapter import fileadapter
     12 from feedwarrior.entry import entry
     13 
     14 logging.basicConfig(level=logging.DEBUG)
     15 logg = logging.getLogger()
     16 
     17 
     18 class TestFileadapter(unittest.TestCase):
     19     
     20     def setUp(self):
     21         uu = uuid.uuid4()
     22         self.feed_uuid = uu
     23         self.path = tempfile.mkdtemp()
     24 
     25 
     26     def tearDown(self):
     27         shutil.rmtree(self.path)
     28 
     29 
     30     def test_put(self):
     31         a = fileadapter(self.path, self.feed_uuid)
     32         uu = uuid.uuid4()
     33 
     34         msg = EmailMessage()
     35         msg.add_header('Date', 'Thu, 2 Jul 2020 12:00:58 +0200')
     36         msg.add_header('Content-Type', 'multipart/mixed')
     37         msg.add_attachment('foo')
     38 
     39         e = entry(uu, msg)
     40         a.put(uu, e)
     41 
     42         logg.debug(a.get(uu))
     43 
     44 
     45 
     46 if __name__ == '__main__':
     47     unittest.main()