ungana

Client application that creates customized .ics files for ticket booking and event reservations
Info | Log | Files | Refs | README

test_fs_store.py (824B)


      1 import tempfile
      2 import unittest
      3 from ungana.store.fs_store import UnganaFSStore
      4 
      5 
      6 class TestUnganaFSStore(unittest.TestCase):
      7 
      8     def test_fs_store_put_and_get(self):
      9         with tempfile.TemporaryDirectory() as tmpdir:
     10             store = UnganaFSStore()
     11 
     12             base_uri = tmpdir
     13             key = "testfile.bin"
     14             data = b"foo bar"
     15 
     16             result_uri = store.put(base_uri, key, data)
     17             self.assertTrue(result_uri.startswith("file://"))
     18 
     19             retrieved = store.get(base_uri, key)
     20             self.assertEqual(retrieved, b"foo bar")
     21 
     22     def test_fs_store_get_missing_raises(self):
     23         with tempfile.TemporaryDirectory() as tmpdir:
     24             store = UnganaFSStore()
     25 
     26             with self.assertRaises(FileNotFoundError):
     27                 store.get(tmpdir, "does_not_exist.bin")