def test_update_non_existing_document(mongodb_backend): attributes = {'foo': 'bar', 'baz': 1243, 'd': {1: 3, 4: 5}, 'l': [1, 2, 3, 4]} doc = Document(attributes) doc.foobar = 'baz' with pytest.raises(Document.DoesNotExist): mongodb_backend.update(doc,['foobar']) mongodb_backend.commit() with pytest.raises(Document.DoesNotExist): assert mongodb_backend.get(Document,{'foobar' : 'baz'})
def test_basics(mongodb_backend): attributes = {'foo': 'bar', 'baz': 1243, 'd': {1: 3, 4: 5}, 'l': [1, 2, 3, 4]} doc = Document(attributes) mongodb_backend.save(doc) mongodb_backend.commit() doc.foobar = 'baz' mongodb_backend.update(doc,['foobar']) mongodb_backend.commit() assert mongodb_backend.get(Document,{'foobar' : 'baz'}) == doc
def test_update_non_existing_document(mongodb_backend): attributes = { "foo": "bar", "baz": 1243, "d": { 1: 3, 4: 5 }, "l": [1, 2, 3, 4] } doc = Document(attributes) doc.foobar = "baz" with pytest.raises(Document.DoesNotExist): mongodb_backend.update(doc, ["foobar"]) mongodb_backend.commit() with pytest.raises(Document.DoesNotExist): assert mongodb_backend.get(Document, {"foobar": "baz"})
def test_basics(mongodb_backend): attributes = { "foo": "bar", "baz": 1243, "d": { 1: 3, 4: 5 }, "l": [1, 2, 3, 4] } doc = Document(attributes) mongodb_backend.save(doc) mongodb_backend.commit() doc.foobar = "baz" mongodb_backend.update(doc, ["foobar"]) mongodb_backend.commit() assert mongodb_backend.get(Document, {"foobar": "baz"}) == doc