Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test TidesDB Python Bindings
name: TidesDB Python Workflow

on:
push:
Expand All @@ -15,7 +15,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.11']

steps:
- name: Checkout Python bindings
Expand All @@ -25,8 +25,15 @@ jobs:
uses: actions/checkout@v4
with:
repository: tidesdb/tidesdb
ref: master
path: tidesdb-core

- name: Show TidesDB version
working-directory: tidesdb-core
run: |
echo "Building TidesDB from commit:"
git log -1 --oneline

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
Expand Down Expand Up @@ -120,10 +127,16 @@ jobs:
run: |
pip install -e .

# Run tests
# Verify library can be loaded
- name: Verify TidesDB library
run: |
python -c "from tidesdb import TidesDB; print('TidesDB library loaded successfully')"

# Run tests with verbose output
- name: Run tests
run: |
pytest test_tidesdb.py -v --cov=tidesdb --cov-report=xml --cov-report=term
pytest -v --tb=short -x
timeout-minutes: 60

# Upload coverage
- name: Upload coverage to Codecov
Expand All @@ -135,34 +148,6 @@ jobs:
name: codecov-umbrella
fail_ci_if_error: false

lint:
name: Lint and Format Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install linting tools
run: |
python -m pip install --upgrade pip
pip install black flake8 mypy

- name: Check formatting with black
run: |
black --check --line-length 100 tidesdb.py test_tidesdb.py

- name: Lint with flake8
run: |
flake8 tidesdb.py test_tidesdb.py --max-line-length=100 --ignore=E203,W503

- name: Type check with mypy
run: |
mypy tidesdb.py --ignore-missing-imports
continue-on-error: true

package:
name: Build Package
Expand Down
10 changes: 0 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Python
__pycache__/
*.py[cod]
*$py.class
Expand All @@ -19,23 +18,14 @@ wheels/
*.egg-info/
.installed.cfg
*.egg

# Testing
.pytest_cache/
.coverage
htmlcov/
.tox/

# IDE
.vscode/
.idea/
*.swp
*.swo
*~

# OS
.DS_Store
Thumbs.db

# Test database
test_db/
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ dev = [

[tool.black]
line-length = 100
target-version = ['py37', 'py38', 'py39', 'py310', 'py311', 'py312']
target-version = ['py37', 'py38', 'py39', 'py310', 'py311', 'py312', 'py313']
include = '\.pyi?$'

[tool.isort]
Expand Down
49 changes: 33 additions & 16 deletions tests/test_tidesdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,17 @@ def test_context_manager(self):
"""Test database as context manager."""
with TidesDB(self.test_db_path) as db:
self.assertIsNotNone(db)
# Create a CF with background compaction disabled
config = ColumnFamilyConfig(enable_background_compaction=False)
db.create_column_family("test_cf", config)
# Database should be closed after context

def test_create_drop_column_family(self):
"""Test creating and dropping column families."""
with TidesDB(self.test_db_path) as db:
# Create with default config
db.create_column_family("test_cf")
# Create with background compaction disabled
config = ColumnFamilyConfig(enable_background_compaction=False)
db.create_column_family("test_cf", config)

# Verify it exists
cf_list = db.list_column_families()
Expand Down Expand Up @@ -92,10 +96,11 @@ def test_create_column_family_with_config(self):
def test_list_column_families(self):
"""Test listing column families."""
with TidesDB(self.test_db_path) as db:
# Create multiple column families
# Create multiple column families with background compaction disabled
config = ColumnFamilyConfig(enable_background_compaction=False)
cf_names = ["cf1", "cf2", "cf3"]
for name in cf_names:
db.create_column_family(name)
db.create_column_family(name, config)

# List them
cf_list = db.list_column_families()
Expand All @@ -107,7 +112,8 @@ def test_list_column_families(self):
def test_transaction_put_get_delete(self):
"""Test basic CRUD operations with transactions."""
with TidesDB(self.test_db_path) as db:
db.create_column_family("test_cf")
config = ColumnFamilyConfig(enable_background_compaction=False)
db.create_column_family("test_cf", config)

# Put data
with db.begin_txn() as txn:
Expand Down Expand Up @@ -136,7 +142,8 @@ def test_transaction_put_get_delete(self):
def test_transaction_with_ttl(self):
"""Test transactions with TTL."""
with TidesDB(self.test_db_path) as db:
db.create_column_family("test_cf")
config = ColumnFamilyConfig(enable_background_compaction=False)
db.create_column_family("test_cf", config)

# Put with TTL (2 seconds from now)
ttl = int(time.time()) + 2
Expand All @@ -160,7 +167,8 @@ def test_transaction_with_ttl(self):
def test_multi_operation_transaction(self):
"""Test transaction with multiple operations."""
with TidesDB(self.test_db_path) as db:
db.create_column_family("test_cf")
config = ColumnFamilyConfig(enable_background_compaction=False)
db.create_column_family("test_cf", config)

# Multiple operations in one transaction
with db.begin_txn() as txn:
Expand All @@ -181,7 +189,8 @@ def test_multi_operation_transaction(self):
def test_transaction_rollback(self):
"""Test transaction rollback."""
with TidesDB(self.test_db_path) as db:
db.create_column_family("test_cf")
config = ColumnFamilyConfig(enable_background_compaction=False)
db.create_column_family("test_cf", config)

# Put some data and rollback
with db.begin_txn() as txn:
Expand All @@ -196,7 +205,8 @@ def test_transaction_rollback(self):
def test_transaction_auto_rollback_on_exception(self):
"""Test transaction automatically rolls back on exception."""
with TidesDB(self.test_db_path) as db:
db.create_column_family("test_cf")
config = ColumnFamilyConfig(enable_background_compaction=False)
db.create_column_family("test_cf", config)

# Exception in context manager should trigger rollback
try:
Expand All @@ -214,7 +224,8 @@ def test_transaction_auto_rollback_on_exception(self):
def test_iterator_forward(self):
"""Test forward iteration."""
with TidesDB(self.test_db_path) as db:
db.create_column_family("test_cf")
config = ColumnFamilyConfig(enable_background_compaction=False)
db.create_column_family("test_cf", config)

# Insert test data
test_data = {
Expand Down Expand Up @@ -251,7 +262,8 @@ def test_iterator_forward(self):
def test_iterator_backward(self):
"""Test backward iteration."""
with TidesDB(self.test_db_path) as db:
db.create_column_family("test_cf")
config = ColumnFamilyConfig(enable_background_compaction=False)
db.create_column_family("test_cf", config)

# Insert test data
test_data = {
Expand Down Expand Up @@ -286,7 +298,8 @@ def test_iterator_backward(self):
def test_iterator_as_python_iterator(self):
"""Test iterator as Python iterator."""
with TidesDB(self.test_db_path) as db:
db.create_column_family("test_cf")
config = ColumnFamilyConfig(enable_background_compaction=False)
db.create_column_family("test_cf", config)

# Insert test data
test_data = {
Expand Down Expand Up @@ -439,7 +452,8 @@ def test_compression_algorithms(self):
def test_pickle_support(self):
"""Test storing Python objects with pickle."""
with TidesDB(self.test_db_path) as db:
db.create_column_family("test_cf")
config = ColumnFamilyConfig(enable_background_compaction=False)
db.create_column_family("test_cf", config)

# Store complex Python object
test_obj = {
Expand Down Expand Up @@ -476,15 +490,17 @@ def test_error_handling(self):
db.drop_column_family("nonexistent_cf")

# Try to get from non-existent CF
db.create_column_family("test_cf")
config = ColumnFamilyConfig(enable_background_compaction=False)
db.create_column_family("test_cf", config)
with db.begin_read_txn() as txn:
with self.assertRaises(TidesDBException):
txn.get("nonexistent_cf", b"key")

def test_large_values(self):
"""Test storing large values."""
with TidesDB(self.test_db_path) as db:
db.create_column_family("test_cf")
config = ColumnFamilyConfig(enable_background_compaction=False)
db.create_column_family("test_cf", config)

# Store 1MB value
large_value = b"x" * (1024 * 1024)
Expand All @@ -502,7 +518,8 @@ def test_large_values(self):
def test_many_keys(self):
"""Test storing many keys."""
with TidesDB(self.test_db_path) as db:
db.create_column_family("test_cf")
config = ColumnFamilyConfig(enable_background_compaction=False)
db.create_column_family("test_cf", config)

num_keys = 1000

Expand Down
Loading
Loading