objectstore: add HostTree class to access host fs
Simple new object that should expose the root file system with the same API as `objectstore.Object` but as read-only. This means that the `read` call works exactly as for `Object` but `write` raises an exception. Add tests to specifically check the read-only properties.
This commit is contained in:
parent
01efa9f817
commit
457f21a336
2 changed files with 42 additions and 0 deletions
|
|
@ -263,6 +263,21 @@ class TestObjectStore(unittest.TestCase):
|
|||
assert os.path.exists(f"{object_store.refs}/b/A")
|
||||
assert os.path.exists(f"{object_store.refs}/b/B")
|
||||
|
||||
def test_host_tree(self):
|
||||
object_store = objectstore.ObjectStore(self.store)
|
||||
host = objectstore.HostTree(object_store)
|
||||
|
||||
# check we cannot call `write`
|
||||
with self.assertRaises(ValueError):
|
||||
with host.write() as _:
|
||||
pass
|
||||
|
||||
# check we actually cannot write to the path
|
||||
with host.read() as path:
|
||||
p = Path(f"{path}/osbuild-test-file")
|
||||
with self.assertRaises(OSError):
|
||||
p.touch()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue