def test_write_2(): obj1 = {'foo': {'bar': 'baz'}} target = Target('foo:bar') obj2 = target.write(obj1, 'qux') assert target.read(obj1) == 'baz' assert target.read(obj2) == 'qux' obj3 = target.delete(obj1) assert 'baz' not in obj3['foo']
def test_write_1(): obj1 = {'foo': 42} target = Target('foo') obj2 = target.write(obj1, 'bar') assert target.read(obj1) == 42 assert target.read(obj2) == 'bar' obj3 = target.delete(obj1) assert 'foo' not in obj3
def test_read_2(): obj = {'one': {'two': None}} target = Target('one:two:three') with pytest.raises(NotFound): target.read(obj)
def test_read(): obj1 = {'foo': 42, 'bar': ['baz', 'qux']} obj2 = {'one': 42, 'two': {'three': 4}} target = Target('foo') assert target.read(obj1) == 42 with pytest.raises(NotFound): target.read(obj2) target = Target('foo:42') with pytest.raises(WrongType): target.read(obj1) with pytest.raises(NotFound): target.read(obj2) target = Target('bar:baz') with pytest.raises(WrongType): target.read(obj1) with pytest.raises(NotFound): target.read(obj2) target = Target('bar:qux') with pytest.raises(WrongType): target.read(obj1) with pytest.raises(NotFound): target.read(obj2) target = Target('two:three') with pytest.raises(NotFound): target.read(obj1) assert target.read(obj2) == 4