Ejemplo n.º 1
0
    def test_update(self):
        """Test that a database will commit both inserts and deletes using the
        update method.
        """
        db = OrientDatabase(DB_URI,
                            _serialize_tuple,
                            _deserialize_tuple,
                            indexes={'name': lambda tup: [tup[1].encode()]},
                            flag='c',
                            _size=1024**2)

        db.put('1', (1, "foo", "bar"))
        db.put('2', (2, "alice", "Alice's data"))
        db.put('3', (3, "bob", "Bob's data"))

        db.update([('4', (4, 'charlie', "Charlie's data"))], ['1'])

        self.assertEqual(['2', '3', '4'], db.keys())
Ejemplo n.º 2
0
    def test_update_replace_index(self):
        """Test that update will properly update insert records that have
        the same index value of a deleted record.
        - insert items should be added
        - inserted items index should be correct
        - deleted items should be removed
        """
        db = OrientDatabase(DB_URI,
                            _serialize_tuple,
                            _deserialize_tuple,
                            indexes={'name': lambda tup: [tup[1].encode()]},
                            flag='c',
                            _size=1024**2)
        db.put('1', (1, "foo", "bar"))
        db.put('2', (2, "alice", "Alice's data"))
        db.put('3', (3, "bob", "Bob's data"))

        db.update([('4', (4, 'foo', "foo's data"))], ['1'])

        self.assertEqual(['2', '3', '4'], db.keys())
        self.assertEqual((4, 'foo', "foo's data"), db.get('foo', index='name'))