Test database creation and schema initialization.
()
| 23 | |
| 24 | |
| 25 | def test_database_initialization(): |
| 26 | """Test database creation and schema initialization.""" |
| 27 | print("Testing database initialization...") |
| 28 | |
| 29 | with tempfile.TemporaryDirectory() as tmpdir: |
| 30 | db_path = Path(tmpdir) / "test.db" |
| 31 | ContainerDatabase(db_path) |
| 32 | |
| 33 | # Verify database file exists |
| 34 | assert db_path.exists(), "Database file was not created" |
| 35 | |
| 36 | # Verify tables exist |
| 37 | conn = sqlite3.connect(db_path) |
| 38 | cursor = conn.cursor() |
| 39 | cursor.execute( |
| 40 | "SELECT name FROM sqlite_master WHERE type='table' AND name='containers'" |
| 41 | ) |
| 42 | result = cursor.fetchone() |
| 43 | conn.close() |
| 44 | |
| 45 | assert result is not None, "containers table was not created" |
| 46 | |
| 47 | print("✓ Database initialization test passed") |
| 48 | |
| 49 | |
| 50 | def test_record_operations(): |