def testMoveToNegative(self): env = upscaledb.env() env.create("test.db") db = env.create_db(1) try: c = upscaledb.cursor() except TypeError: pass try: c = upscaledb.cursor("blah") except TypeError: pass try: c = upscaledb.cursor(db) c.move_to(upscaledb.UPS_CURSOR_FIRST) except upscaledb.error, (errno, string): assert upscaledb.UPS_KEY_NOT_FOUND == errno
def testGetOverwrite(self): env = upscaledb.env() env.create("test.db") db = env.create_db(1) c = upscaledb.cursor(db) try: c.overwrite("asdf") except upscaledb.error, (errno, string): assert upscaledb.UPS_CURSOR_IS_NIL == errno
def testGetRecordNegative(self): env = upscaledb.env() env.create("test.db") db = env.create_db(1) c = upscaledb.cursor(db) try: c.get_record() except upscaledb.error, (errno, string): assert upscaledb.UPS_CURSOR_IS_NIL == errno
def testGetDuplicateCountNegative(self): env = upscaledb.env() env.create("test.db") db = env.create_db(1, upscaledb.UPS_ENABLE_DUPLICATE_KEYS) c = upscaledb.cursor(db) try: c.get_duplicate_count() except upscaledb.error, (errno, string): assert upscaledb.UPS_CURSOR_IS_NIL == errno
def testClone(self): env = upscaledb.env() env.create("test.db") db = env.create_db(1) c = upscaledb.cursor(db) clone = c.clone() c.close() clone.close() db.close()
def testFindNegative(self): env = upscaledb.env() env.create("test.db") db = env.create_db(1) db.insert(None, "key1", "value1") db.insert(None, "key2", "value2") db.insert(None, "key3", "value3") c = upscaledb.cursor(db) try: c.find("key4") except upscaledb.error, (errno, string): assert upscaledb.UPS_KEY_NOT_FOUND == errno
def testCloneNegative(self): env = upscaledb.env() env.create("test.db") db = env.create_db(1) c = upscaledb.cursor(db) try: clone = c.clone(13) except TypeError: pass c.close() db.close() env.close()
def testErase(self): env = upscaledb.env() env.create("test.db") db = env.create_db(1) c = upscaledb.cursor(db) c.insert("key1", "value1") assert "key1" == c.get_key() assert "value1" == c.get_record() c.erase() try: c.find("key1") except upscaledb.error, (errno, string): assert upscaledb.UPS_KEY_NOT_FOUND == errno
def testMoveTo(self): env = upscaledb.env() env.create("test.db") db = env.create_db(1) db.insert(None, "key1", "value1") db.insert(None, "key2", "value2") db.insert(None, "key3", "value3") c = upscaledb.cursor(db) c.move_to(upscaledb.UPS_CURSOR_FIRST) c.move_to(upscaledb.UPS_CURSOR_NEXT) c.move_to(upscaledb.UPS_CURSOR_LAST) c.close() db.close() env.close()
def testCursor(self): env = upscaledb.env() env.create("test.db", upscaledb.UPS_ENABLE_TRANSACTIONS) db = env.create_db(1) txn = upscaledb.txn(env) c = upscaledb.cursor(db, txn) c.insert("key1", "value1") c.insert("key2", "value2") c.insert("key3", "value3") c.find("key1") c.erase() try: c.find("key2") except upscaledb.error, (errno, strerror): assert upscaledb.UPS_KEY_NOT_FOUND == errno
def testInsertRecno(self): env = upscaledb.env() env.create("test.db") db = env.create_db(1, upscaledb.UPS_RECORD_NUMBER32) c = upscaledb.cursor(db) c.insert(1, "value1") assert 1 == c.get_key() assert "value1" == c.get_record() c.insert(2, "value2") c.insert(3, "value3") try: c.insert("1", "blah") except TypeError: pass c.close() db.close() env.close()
def testInsert(self): env = upscaledb.env() env.create("test.db") db = env.create_db(1) c = upscaledb.cursor(db) c.insert("key1", "value1") assert "key1" == c.get_key() assert "value1" == c.get_record() c.insert("key3", "value3") assert "key3" == c.get_key() assert "value3" == c.get_record() c.insert("key2", "value2") assert "key2" == c.get_key() assert "value2" == c.get_record() c.close() db.close() env.close()
def testGetDuplicateCount(self): env = upscaledb.env() env.create("test.db") db = env.create_db(1, upscaledb.UPS_ENABLE_DUPLICATE_KEYS) c = upscaledb.cursor(db) c.insert("key1", "value1") assert 1 == c.get_duplicate_count() c.insert("key1", "value2", upscaledb.UPS_DUPLICATE) assert 2 == c.get_duplicate_count() c.insert("key1", "value3", upscaledb.UPS_DUPLICATE) assert 3 == c.get_duplicate_count() c.erase() c.move_to(upscaledb.UPS_CURSOR_FIRST) assert 2 == c.get_duplicate_count() c.close() db.close() env.close()
def testEraseNegative(self): env = upscaledb.env() env.create("test.db") db = env.create_db(1) c = upscaledb.cursor(db) try: c.erase(3) except TypeError: pass try: c.erase("a", "key2", "value2") except TypeError: pass try: c.erase() except upscaledb.error, (errno, string): assert upscaledb.UPS_CURSOR_IS_NIL == errno
def testGetRecord(self): env = upscaledb.env() env.create("test.db") db = env.create_db(1) db.insert(None, "key1", "value1") db.insert(None, "key2", "value2") db.insert(None, "key3", "value3") c = upscaledb.cursor(db) c.move_to(upscaledb.UPS_CURSOR_FIRST) assert "value1" == c.get_record() c.move_to(upscaledb.UPS_CURSOR_NEXT) assert "value2" == c.get_record() c.move_to(upscaledb.UPS_CURSOR_LAST) assert "value3" == c.get_record() c.close() db.close() env.close()
def testFindRecno(self): env = upscaledb.env() env.create("test.db") db = env.create_db(1, upscaledb.UPS_RECORD_NUMBER64) db.insert(None, 1, "value1") db.insert(None, 2, "value2") db.insert(None, 3, "value3") c = upscaledb.cursor(db) c.find(1) assert 1 == c.get_key() assert "value1" == c.get_record() try: c.find("1") except TypeError: pass c.close() db.close() env.close()
def testInsertNegative(self): env = upscaledb.env() env.create("test.db") db = env.create_db(1) c = upscaledb.cursor(db) try: c.insert(3, "value1") except TypeError: pass try: c.insert("a", "key2", "value2") except TypeError: pass try: c.insert() except TypeError: pass try: c.insert("key1", "value1") c.insert("key1", "value1") except upscaledb.error, (errno, string): assert upscaledb.UPS_DUPLICATE_KEY == errno
def testGetRecordSize(self): env = upscaledb.env() env.create("test.db") db = env.create_db(1, upscaledb.UPS_ENABLE_DUPLICATE_KEYS) c = upscaledb.cursor(db) c.insert("key1", "v") c.insert("key2", "va") c.insert("key3", "val") c.insert("key4", "valu", upscaledb.UPS_DUPLICATE) c.insert("key4", "value", upscaledb.UPS_DUPLICATE) c.move_to(upscaledb.UPS_CURSOR_FIRST) assert 1 == c.get_record_size() c.move_to(upscaledb.UPS_CURSOR_NEXT) assert 2 == c.get_record_size() c.move_to(upscaledb.UPS_CURSOR_NEXT) assert 3 == c.get_record_size() c.move_to(upscaledb.UPS_CURSOR_NEXT) assert 4 == c.get_record_size() c.move_to(upscaledb.UPS_CURSOR_NEXT) assert 5 == c.get_record_size() c.close() db.close() env.close()