コード例 #1
0
ファイル: test_update.py プロジェクト: adewes/blitzdb
    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'})
コード例 #2
0
ファイル: test_update.py プロジェクト: adewes/blitzdb
    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
コード例 #3
0
    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'})
コード例 #4
0
    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
コード例 #5
0
    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"})
コード例 #6
0
    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