This reverts commit 3d4652420c.
This commit is contained in:
@@ -1,54 +0,0 @@
|
||||
"""
|
||||
Unit tests for MobileConfigurationView API endpoint.
|
||||
"""
|
||||
from django.urls import reverse
|
||||
from rest_framework import status
|
||||
from rest_framework.test import APITestCase
|
||||
|
||||
from lms.djangoapps.mobile_api.models import MobileConfig
|
||||
|
||||
|
||||
class MobileConfigurationViewTest(APITestCase):
|
||||
"""
|
||||
Test cases for MobileConfigurationView API endpoint.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Set up test data and common test utilities.
|
||||
"""
|
||||
self.url = reverse('mobile-configurations', kwargs={'api_version': 'v1'})
|
||||
|
||||
def test_get_mobile_configurations_empty_database(self):
|
||||
"""
|
||||
Test API response when no configurations exist in database.
|
||||
"""
|
||||
# Act
|
||||
response = self.client.get(self.url)
|
||||
|
||||
# Assert
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
expected_data = {"iap_configs": {}}
|
||||
self.assertEqual(response.data, expected_data)
|
||||
|
||||
def test_get_mobile_configurations_with_regular_configs(self):
|
||||
"""
|
||||
Test API response with regular (non-IAP) configurations.
|
||||
"""
|
||||
# Arrange
|
||||
MobileConfig.objects.create(name='app_version', value='2.1.0')
|
||||
MobileConfig.objects.create(name='enable_dark_mode', value='true')
|
||||
MobileConfig.objects.create(name='api_timeout', value='30')
|
||||
|
||||
# Act
|
||||
response = self.client.get(self.url)
|
||||
|
||||
# Assert
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
expected_data = {
|
||||
"iap_configs": {},
|
||||
"app_version": "2.1.0",
|
||||
"enable_dark_mode": "true",
|
||||
"api_timeout": "30"
|
||||
}
|
||||
self.assertEqual(response.data, expected_data)
|
||||
@@ -2,15 +2,14 @@
|
||||
URLs for mobile API
|
||||
"""
|
||||
|
||||
|
||||
from django.urls import include, path
|
||||
|
||||
from .users.views import my_user_info
|
||||
from .views import MobileConfigurationView
|
||||
|
||||
urlpatterns = [
|
||||
path('users/', include('lms.djangoapps.mobile_api.users.urls')),
|
||||
path('my_user_info', my_user_info, name='user-info'),
|
||||
path('notifications/', include('lms.djangoapps.mobile_api.notifications.urls')),
|
||||
path('course_info/', include('lms.djangoapps.mobile_api.course_info.urls')),
|
||||
path('configurations/', MobileConfigurationView.as_view(), name='mobile-configurations')
|
||||
]
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
"""
|
||||
Views for the mobile API.
|
||||
"""
|
||||
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.views import APIView
|
||||
|
||||
from lms.djangoapps.mobile_api.models import MobileConfig
|
||||
|
||||
|
||||
class MobileConfigurationView(APIView):
|
||||
"""
|
||||
API endpoint that returns mobile configuration data.
|
||||
"""
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
"""
|
||||
Get all mobile configurations.
|
||||
"""
|
||||
return Response(MobileConfig.get_structured_configs())
|
||||
Reference in New Issue
Block a user