Skip to content

Commit

Permalink
add account test
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-nork committed Sep 13, 2023
1 parent c83369d commit 0954964
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions chirps/account/tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
"""Tests for the account application."""
from django.contrib.auth.models import User
from django.test import TestCase
from django.urls import reverse

from .models import Profile


class AccountTests(TestCase):
"""Main test class for the account application."""
Expand Down Expand Up @@ -132,3 +135,20 @@ def test_password_change_validation(self):
},
)
self.assertEqual(response.status_code, 200)

def test_masked_api_keys(self):
"""Verify that the masked API keys are returned correctly."""
username = 'test_user'
password = 'test_password'
email = '[email protected]'

# Create a new user and profile
user = User.objects.create_user(username, email, password)
profile = Profile.objects.create(
user=user, anthropic_api_key='anthropic123456', cohere_key='cohere123456', openai_api_key='openai123456'
)

# Check the masked API keys
self.assertEqual(profile.masked_anthropic_api_key, 'anthro*********')
self.assertEqual(profile.masked_cohere_key, 'cohere******')
self.assertEqual(profile.masked_openai_api_key, 'openai******')

0 comments on commit 0954964

Please sign in to comment.