tests/persistence_test.py
raw| 1 | from errbot.storage import StoreMixin |
| 2 | from errbot.storage.memory import MemoryStoragePlugin |
| 3 | |
| 4 | |
| 5 | def test_simple_store_retreive(): |
| 6 | sm = StoreMixin() |
| 7 | sm.open_storage(MemoryStoragePlugin(None), "ns") |
| 8 | sm["toto"] = "titui" |
| 9 | assert sm["toto"] == "titui" |
| 10 | |
| 11 | |
| 12 | def test_mutable(): |
| 13 | sm = StoreMixin() |
| 14 | sm.open_storage(MemoryStoragePlugin(None), "ns") |
| 15 | sm["toto"] = [1, 3] |
| 16 | |
| 17 | with sm.mutable("toto") as titi: |
| 18 | titi[1] = 5 |
| 19 | |
| 20 | assert sm["toto"] == [1, 5] |