def test_json_replace_empty_data(self): with pytest.raises(ValueError) as excinfo: JSONReplace('attrs', {}) assert '"data" cannot be empty' in str(excinfo.value)
def test_json_replace_pairs(self): self.obj.attrs = JSONReplace("attrs", {"$.int": 101, "$.int2": 102}) self.obj.save() self.obj.refresh_from_db() assert self.obj.attrs["int"] == 101 assert "int2" not in self.obj.attrs
def test_json_replace_pairs(self): self.obj.attrs = JSONReplace('attrs', {'$.int': 101, '$.int2': 102}) self.obj.save() self.obj.refresh_from_db() assert self.obj.attrs['int'] == 101 assert 'int2' not in self.obj.attrs