def test_save(self): n = m.Note({ "text": "what a beautiful moment <333", "public": False, "owner": 1, "ref": "Genesis 48:11", "type": "note" }) n.text = 'Seemingly ok note... <a href="javascript:alert(8007)">Click me</a>' n.save() assert n.text == 'Seemingly ok note... <a>Click me</a>' n.delete()
def test_equality_and_identity(self): attrs = { "ref": "Psalms 145:22", "text": "Not a part of this Psalm, but tradition to read it at the end of recitation in Psukei d'Zimrah", "anchorText": "Psalm 115:18", "owner": 7934, "type": "note", "public": True } model.Note(attrs).save( ) # added to make sure there is a note in the db, if the table is truncated or not extant. n1 = model.Note(attrs) n2 = model.Note(attrs) n3 = model.Note() assert n1 is not n2 assert n1 == n2 assert not n1.same_record(n2) assert n1 != n3 assert not n1.same_record(n3) n4 = model.Note().load({"ref": "Psalms 145:22", "owner": 7934}) n5 = model.Note().load({"ref": "Psalms 145:22", "owner": 7934}) assert n4 is not n5 assert n4.same_record(n5) assert not n1.same_record(n5)
def test_attribute_exception(self): attrs = { "ref": "Psalms 150:1", "text": "blah", "anchorText": "blue", "owner": 28, "type": "note", "public": True, "foobar": "blaz" # should raise an exception when loaded } db.notes.remove({"ref": "Psalms 150:1", "owner": 28}) db.notes.save(attrs) with pytest.raises(Exception): model.Note().load({"ref": "Psalms 150:1", "owner": 28}) db.notes.remove({"ref": "Psalms 150:1", "owner": 28})