from models.profile import Profile import os def test_profile(): """Test Profile model CRUD operations. Profile create() sets name, type, tabs (list of tab IDs), scenes, palette_id. """ # Clean up any existing test file (model uses db/profile.json from project root) db_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "db") profile_file = os.path.join(db_dir, "profile.json") if os.path.exists(profile_file): os.remove(profile_file) profiles = Profile() print("Testing create profile") profile_id = profiles.create("test_profile") print(f"Created profile with ID: {profile_id}") assert profile_id is not None assert profile_id in profiles print("\nTesting read profile") profile = profiles.read(profile_id) print(f"Read: {profile}") assert profile is not None assert profile["name"] == "test_profile" assert "tabs" in profile assert "palette_id" in profile assert "type" in profile print("\nTesting update profile") update_data = { "name": "updated_profile", "tabs": ["tab1"], } result = profiles.update(profile_id, update_data) assert result is True updated = profiles.read(profile_id) assert updated["name"] == "updated_profile" assert "tab1" in updated["tabs"] print("\nTesting list profiles") profile_list = profiles.list() print(f"Profile list: {profile_list}") assert profile_id in profile_list print("\nTesting delete profile") deleted = profiles.delete(profile_id) assert deleted is True assert profile_id not in profiles print("\nTesting read after delete") profile = profiles.read(profile_id) assert profile is None print("\nAll profile tests passed!") if __name__ == '__main__': test_profile()