Tests for profile CRUD operations
| 26 | """Tests for profile CRUD operations""" |
| 27 | |
| 28 | def test_create_profile(self, test_db_path, sample_profile): |
| 29 | """Test creating a new profile""" |
| 30 | # Override DB_PATH |
| 31 | import db_ops |
| 32 | db_ops.DB_PATH = test_db_path |
| 33 | |
| 34 | result = create_profile( |
| 35 | sample_profile["user_id"], |
| 36 | sample_profile |
| 37 | ) |
| 38 | assert result is not None |
| 39 | assert result > 0 |
| 40 | |
| 41 | def test_create_duplicate_profile(self, test_db_path, sample_profile): |
| 42 | """Test creating duplicate profile returns None""" |
| 43 | import db_ops |
| 44 | db_ops.DB_PATH = test_db_path |
| 45 | |
| 46 | # Create first profile |
| 47 | create_profile(sample_profile["user_id"], sample_profile) |
| 48 | |
| 49 | # Try to create duplicate |
| 50 | result = create_profile(sample_profile["user_id"], sample_profile) |
| 51 | assert result is None |
| 52 | |
| 53 | def test_get_profile(self, test_db_path, sample_profile): |
| 54 | """Test retrieving a profile""" |
| 55 | import db_ops |
| 56 | db_ops.DB_PATH = test_db_path |
| 57 | |
| 58 | # Create profile |
| 59 | create_profile(sample_profile["user_id"], sample_profile) |
| 60 | |
| 61 | # Retrieve profile |
| 62 | result = get_profile(sample_profile["user_id"]) |
| 63 | assert result is not None |
| 64 | assert result["user_id"] == sample_profile["user_id"] |
| 65 | assert result["version"] == sample_profile["version"] |
| 66 | |
| 67 | def test_get_nonexistent_profile(self, test_db_path): |
| 68 | """Test retrieving nonexistent profile returns None""" |
| 69 | import db_ops |
| 70 | db_ops.DB_PATH = test_db_path |
| 71 | |
| 72 | result = get_profile("nonexistent_user") |
| 73 | assert result is None |
| 74 | |
| 75 | def test_update_profile(self, test_db_path, sample_profile): |
| 76 | """Test updating a profile""" |
| 77 | import db_ops |
| 78 | db_ops.DB_PATH = test_db_path |
| 79 | |
| 80 | # Create profile |
| 81 | create_profile(sample_profile["user_id"], sample_profile) |
| 82 | |
| 83 | # Update profile |
| 84 | updated = sample_profile.copy() |
| 85 | updated["version"] = "0.2" |
nothing calls this directly
no outgoing calls
no test coverage detected