
    ;-h              
           d dl mZ d dlmZ d dlmZmZmZmZ d dl	Z	 e	j                  e	j                  d        e	j                  e      Z ee      Zded	efd
Zddededee   d	ee   fdZy)    )OpenAI)OPENAI_API_KEY)OptionalListDictAnyNz4%(asctime)s - %(name)s - %(levelname)s - %(message)s)levelformat)api_key	test_typereturnc           	      h    ddddddddddd	dd
dd	dddd	dddd	dd}|j                  | i       S )z.Get the configuration for a specific test typeTC_FUNCzEfunctional test cases focusing on valid inputs and expected behaviors   )prefixdescriptioncountTC_NEGzNnegative test cases focusing on invalid inputs, error handling, and edge casesTC_UIz4UI test cases focusing on visual elements and layout   TC_UXzDuser experience test cases focusing on user interaction and workflow	TC_COMPATz@compatibility test cases across different browsers and platformsTC_PERFz@performance test cases focusing on load times and responsiveness)dashboard_functionaldashboard_negativedashboard_uidashboard_uxdashboard_compatibilitydashboard_performance)get)r   base_configss     iD:\Onedrive\OneDrive - Evince Development Pvt. Ltd\automation\ui-based-testcase-generator\ai\generator.pyget_test_type_configr#      s      b!
 k
 Q
 a
 "]$
  ]"
5L@ Ir**    r   summaryselected_typesc                    | st         j                  d       y|rt        |      dk(  rt         j                  d       yt         j                  d|        t         j                  d|        t         j                  dt        |        d       g }|D ][  }t         j                  d	|        t	        |      }|st         j                  d
|        Bd| d|  d|d    d|d    d|d    d| d|d    d}	 t         j                  d| d       t        j                  j                  j                  ddd|d    d| d|d    ddd|dgd d!"      }|j                  d   j                  j                  j                         }|r3t         j                  d#| d$       d%| d&| }	|j                  |	       nt         j                  d'| d       t         j                  d*|        ^ |st         j                  d+       yt         j                  d,t        |       d-       d&d&j#                  |      z   S # t        $ r/}
t         j                  d(| d)t!        |
              Y d}
~
d}
~
ww xY w).z0Generate test cases based on user-selected typesz0No description provided for test case generationNr   z/No test types selected for test case generationz!Generating test cases for types: z	Summary: zDescription length: z charactersz#Starting generation for test type: zSkipping unknown test type: z
        Task Title: z
        Task Description: z

        Generate EXACTLY r   z test cases for r   zA.
        
        For each test case:
        1. Use the prefix r   z!
        2. Focus exclusively on z scenarios
        3. Include detailed steps
        4. Specify expected results
        5. Do not mix with other test types

        Use this EXACT format for each test case:

        Title: a+  _[Number]_[Brief_Title]
        Scenario: [Detailed scenario description]
        Steps to reproduce:
        1. [Step 1]
        2. [Step 2]
        ...
        Expected Result: [What should happen]
        Actual Result: [To be filled during execution]
        Priority: [High/Medium/Low]
        zSending request to OpenAI for z test caseszgpt-4osystemz(You are a QA engineer. Generate EXACTLY  z test cases. Use z as the prefix.)rolecontentusergffffff?i  )modelmessagestemperature
max_tokensz
Generated z test cases successfullyzTEST TYPE: z

zReceived empty response for zError generating z test cases: z$Completed generation for test type: z!Failed to generate any test casesz&Successfully generated test cases for z test types)loggererrorleninfor#   warningclientchatcompletionscreatechoicesmessager+   stripappend	Exceptionstrjoin)r   r%   r&   all_test_casesr   configpromptresponse
test_casestest_cases_with_headeres              r"   generate_test_caserH   1   s   GHS0A5FG
KK3N3CDE
KK)G9%&
KK&s;'7&8DEN# =H	9)EF%i0NN9)EFI &- ( /**:6-;P:Q R "(+, -!!* , x ! 	"	4	KK8;OP{{..55 !)%MfU\oM^^_`i_jj{  }C  DL  }M  |N  N]  $^ $7   6 H "))!,44<<BBDJj3KLM+6ykj\)R&%%&<=!=i[TU 	:9+FG{=H~ 89
KK8^9L8M[YZFKK///  	LL,YK}SVHMN	s   <CI	I:$I55I:) N)openair   config.settingsr   typingr   r   r   r   loggingbasicConfigINFO	getLogger__name__r1   r6   r?   dictr#   rH    r$   r"   <module>rT      s     * , ,    ',,/e f			8	$ 
	'"+C "+D "+HT0C T0# T0DQTI T0aijman T0r$   