예제 #1
0
    def test_count(self):
        """Test that a database with three records, plus an index will
        return the correct count of primary key/values, using `len`.
        """
        db = OrientDatabase(os.path.join(self._temp_dir, 'test_db'),
                            _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"))

        self.assertEqual(3, len(db))

        self.assertEqual(3, db.count())
        self.assertEqual(3, db.count(index="name"))
예제 #2
0
    def test_count(self):
        """Test that a database with three records, plus an index will
        return the correct count of primary key/values, using `len`.
        """
        #logging.basicConfig()
        #log = logging.getLogger("LOG")
        #log.info('OrientDatabaseTest test_count...')
        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"))

        self.assertEqual(3, len(db))

        self.assertEqual(3, db.count())
        self.assertEqual(3, db.count(index="name"))