mirror of
https://github.com/simon987/hexlib.git
synced 2025-04-19 01:36:42 +00:00
36 lines
754 B
Python
36 lines
754 B
Python
import os
|
|
from unittest import TestCase
|
|
|
|
from hexlib.db import PersistentState
|
|
|
|
|
|
class TestPersistentState(TestCase):
|
|
|
|
def tearDown(self) -> None:
|
|
if os.path.exists("state.db"):
|
|
os.remove("state.db")
|
|
|
|
def setUp(self) -> None:
|
|
if os.path.exists("state.db"):
|
|
os.remove("state.db")
|
|
|
|
def test_get_set(self):
|
|
s = PersistentState()
|
|
|
|
val = {"a": 1, "b": "2", "c": b'3', "d": 4.4}
|
|
s["a"]["1"] = val
|
|
|
|
val["id"] = "1"
|
|
|
|
self.assertDictEqual(val, s["a"]["1"])
|
|
|
|
def test_get_set_int_id(self):
|
|
s = PersistentState()
|
|
|
|
val = {"a": 1, "b": "2", "c": b'3', "d": 4.4}
|
|
s["a"][1] = val
|
|
|
|
val["id"] = 1
|
|
|
|
self.assertDictEqual(val, s["a"][1])
|