"""
Integration tests for System module endpoints
Tests settings, prompts, integrations return unified format
"""
from rest_framework import status
from igny8_core.api.tests.test_integration_base import IntegrationTestBase


class SystemIntegrationTestCase(IntegrationTestBase):
    """Integration tests for System module"""
    
    def test_system_status_returns_unified_format(self):
        """Test GET /api/v1/system/status/ returns unified format"""
        response = self.client.get('/api/v1/system/status/')
        
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assert_unified_response_format(response, expected_success=True)
        self.assertIn('data', response.data)
    
    def test_list_prompts_returns_unified_format(self):
        """Test GET /api/v1/system/prompts/ returns unified format"""
        response = self.client.get('/api/v1/system/prompts/')
        
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assert_paginated_response(response)
    
    def test_get_prompt_by_type_returns_unified_format(self):
        """Test GET /api/v1/system/prompts/by_type/{type}/ returns unified format"""
        response = self.client.get('/api/v1/system/prompts/by_type/clustering/')
        
        # May return 404 if no prompt exists, but should still be unified format
        self.assertIn(response.status_code, [status.HTTP_200_OK, status.HTTP_404_NOT_FOUND])
        self.assert_unified_response_format(response)
    
    def test_list_account_settings_returns_unified_format(self):
        """Test GET /api/v1/system/settings/account/ returns unified format"""
        response = self.client.get('/api/v1/system/settings/account/')
        
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assert_paginated_response(response)
    
    def test_get_integration_settings_returns_unified_format(self):
        """Test GET /api/v1/system/settings/integrations/{pk}/ returns unified format"""
        response = self.client.get('/api/v1/system/settings/integrations/openai/')
        
        # May return 404 if not configured, but should still be unified format
        self.assertIn(response.status_code, [status.HTTP_200_OK, status.HTTP_404_NOT_FOUND])
        self.assert_unified_response_format(response)

