コード例 #1
0
 def test_json_replace_empty_data(self):
     with pytest.raises(ValueError) as excinfo:
         JSONReplace('attrs', {})
     assert '"data" cannot be empty' in str(excinfo.value)
コード例 #2
0
 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
コード例 #3
0
 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