diff --git a/commerce_coordinator/apps/commercetools/tests/test_views.py b/commerce_coordinator/apps/commercetools/tests/test_views.py index 3784b1e4f..5fa629684 100644 --- a/commerce_coordinator/apps/commercetools/tests/test_views.py +++ b/commerce_coordinator/apps/commercetools/tests/test_views.py @@ -100,11 +100,13 @@ class MobileStandalonePriceChangeViewTests(APITestCase): def setUp(self): """Set up test users""" + super().setUp() User.objects.create_user(username=self.test_user_username, password=self.test_password) User.objects.create_user(username=self.test_staff_username, password=self.test_password, is_staff=True) def tearDown(self): """Clean up after each test""" + super().tearDown() TieredCache.dangerous_clear_all_tiers() self.client.logout() @@ -139,56 +141,13 @@ class MobileCourseVariantAddViewTests(APITestCase): def setUp(self): """Set up test users""" + super().setUp() User.objects.create_user(username=self.test_user_username, password=self.test_password) User.objects.create_user(username=self.test_staff_username, password=self.test_password, is_staff=True) def tearDown(self): """Clean up after each test""" - TieredCache.dangerous_clear_all_tiers() - self.client.logout() - - def test_view_returns_ok_for_admin_user(self): - """Ensure a staff user gets 200 OK""" - self.client.login(username=self.test_staff_username, password=self.test_password) - response = self.client.post(self.url, data=EXAMPLE_COMMERCETOOLS_COURSE_VARIANT_ADD_MESSAGE, format='json') - self.assertEqual(response.status_code, 200) - - def test_view_forbidden_for_non_admin_user(self): - """Ensure a non-staff user gets 403 Forbidden""" - self.client.login(username=self.test_user_username, password=self.test_password) - response = self.client.post(self.url, data=EXAMPLE_COMMERCETOOLS_COURSE_VARIANT_ADD_MESSAGE, format='json') - self.assertEqual(response.status_code, 403) - - def test_missing_payload_returns_400(self): - """Check response for empty POST body""" - self.client.login(username=self.test_staff_username, password=self.test_password) - response = self.client.post(self.url, data={}, format='json') - # Assuming view should still return 200 (as per current logic). Change if behavior differs. - self.assertEqual(response.status_code, 200) - - def test_unauthenticated_user_returns_401(self): - """Ensure unauthenticated requests are denied with 401""" - response = self.client.post(self.url, data=EXAMPLE_COMMERCETOOLS_COURSE_VARIANT_ADD_MESSAGE, format='json') - self.assertEqual(response.status_code, 401) - - -class MobileCourseCreateViewTests(APITestCase): - """Tests for MobileCourseVariantAddView""" - url = reverse('commercetools:mobile-course-variant-add') - - client_class = APIClient - - test_user_username = 'test_user' - test_staff_username = 'test_staff_user' - test_password = 'test_password' - - def setUp(self): - """Set up test users""" - User.objects.create_user(username=self.test_user_username, password=self.test_password) - User.objects.create_user(username=self.test_staff_username, password=self.test_password, is_staff=True) - - def tearDown(self): - """Clean up after each test""" + super().tearDown() TieredCache.dangerous_clear_all_tiers() self.client.logout() diff --git a/commerce_coordinator/apps/commercetools/urls.py b/commerce_coordinator/apps/commercetools/urls.py index ed0d78b52..078d6b9a7 100644 --- a/commerce_coordinator/apps/commercetools/urls.py +++ b/commerce_coordinator/apps/commercetools/urls.py @@ -5,7 +5,6 @@ from django.urls import include, path from commerce_coordinator.apps.commercetools.views import ( - MobileCourseCreateView, MobileCourseVariantAddView, MobileStandalonePriceChangeView, OrderFulfillView, @@ -19,7 +18,6 @@ # EventBridge / CloudWatch Endpoints path('fulfill', OrderFulfillView.as_view(), name='fulfill'), path('mobile-course-variant-add', MobileCourseVariantAddView.as_view(), name='mobile-course-variant-add'), - path('mobile-course-create', MobileCourseCreateView.as_view(), name='mobile-course-create'), path( 'mobile-standalone-price-change', MobileStandalonePriceChangeView.as_view(), diff --git a/commerce_coordinator/apps/commercetools/views.py b/commerce_coordinator/apps/commercetools/views.py index 0a26fe3e4..0907cf846 100644 --- a/commerce_coordinator/apps/commercetools/views.py +++ b/commerce_coordinator/apps/commercetools/views.py @@ -98,29 +98,6 @@ def post(self, request): return Response(status=status.HTTP_200_OK) -class MobileCourseCreateView(SingleInvocationAPIView): - """Mobile Course Create View""" - - authentication_classes = [JwtBearerAuthentication, SessionAuthentication] - permission_classes = [IsAdminUser] - - def post(self, request): - """Receive a message from commerce tools forwarded by AWS event bridge""" - - tag = type(self).__name__ - - input_data = { - **request.data - } - - logger.info( - f'[CT-{tag}] Message received from commercetools ' - f'Course Create with details: {input_data}' - ) - - return Response(status=status.HTTP_200_OK) - - class MobileCourseVariantAddView(SingleInvocationAPIView): """Mobile Course Variant Add View"""