def test_flush_key(self): DataBag._data = {'foo': {'a': 1, 'b': 2}} data = DataBag.flush('foo.a') assert data is 1 assert DataBag._data == {'foo': {'b': 2}}
def test_flush_invalid_key(self): DataBag._data = {'foo': 42} data = DataBag.flush('foo.a', 'invalid') assert data == 'invalid' assert DataBag._data == {'foo': 42}
def test_flush_all(self): DataBag._data = {'foo': {'a': 1, 'b': 2}} data = DataBag.flush() assert data == {'foo': {'a': 1, 'b': 2}} assert DataBag._data == {}