Add voice channel functionality with WebRTC peer-to-peer audio: - Add VoiceSignalingConsumer for WebRTC signaling and peer coordination - Add GlobalConsumer for real-time presence and voice status updates - Add voice channel type to Channel model with current_voice_channel tracking on UserProfile - Add voice controls UI (mute, deafen, disconnect) in status panel - Add voice member list display in sidebar with avatar support - Add
38 lines
1.5 KiB
Python
38 lines
1.5 KiB
Python
from django.test import TestCase, Client
|
|
from django.urls import reverse
|
|
from django.contrib.auth.models import User
|
|
from chat.models import Channel
|
|
|
|
|
|
class VoiceChannelsTests(TestCase):
|
|
def setUp(self):
|
|
self.user = User.objects.create_user(username='testuser', password='password')
|
|
self.client = Client()
|
|
|
|
def test_voice_credentials_anonymous(self):
|
|
# Anonymous user should be redirected to login
|
|
url = reverse('voice_credentials')
|
|
response = self.client.get(url)
|
|
self.assertEqual(response.status_code, 302)
|
|
|
|
def test_voice_credentials_authenticated(self):
|
|
# Authenticated user should get ICE servers JSON
|
|
self.client.login(username='testuser', password='password')
|
|
url = reverse('voice_credentials')
|
|
response = self.client.get(url)
|
|
self.assertEqual(response.status_code, 200)
|
|
data = response.json()
|
|
self.assertIn('iceServers', data)
|
|
self.assertTrue(len(data['iceServers']) > 0)
|
|
self.assertIn('urls', data['iceServers'][0])
|
|
|
|
def test_channel_model_default_type(self):
|
|
# Default channel type should be 'text'
|
|
channel = Channel.objects.create(name='general', created_by=self.user)
|
|
self.assertEqual(channel.channel_type, 'text')
|
|
|
|
def test_voice_channel_type(self):
|
|
# Can create channel of type 'voice'
|
|
channel = Channel.objects.create(name='Gaming', channel_type='voice', created_by=self.user)
|
|
self.assertEqual(channel.channel_type, 'voice')
|