11/*
2- Copyright 2023 API Testing Authors.
2+ Copyright 2024 API Testing Authors.
33
44Licensed under the Apache License, Version 2.0 (the "License");
55you may not use this file except in compliance with the License.
@@ -63,6 +63,12 @@ func TestGenerators(t *testing.T) {
6363 assert .Equal (t , expectedJavaCode , result )
6464 })
6565
66+ t .Run ("python" , func (t * testing.T ) {
67+ result , err := generator .GetCodeGenerator ("python" ).Generate (nil , testcase )
68+ assert .NoError (t , err )
69+ assert .Equal (t , expectedPythonCode , result )
70+ })
71+
6672 formRequest := & atest.TestCase {Request : testcase .Request }
6773 formRequest .Request .Form = map [string ]string {
6874 "key" : "value" ,
@@ -79,6 +85,12 @@ func TestGenerators(t *testing.T) {
7985 assert .Equal (t , expectedFormRequestJavaCode , result , result )
8086 })
8187
88+ t .Run ("python form HTTP request" , func (t * testing.T ) {
89+ result , err := generator .GetCodeGenerator ("python" ).Generate (nil , formRequest )
90+ assert .NoError (t , err )
91+ assert .Equal (t , expectedFormRequestPythonCode , result , result )
92+ })
93+
8294 cookieRequest := & atest.TestCase {Request : formRequest .Request }
8395 cookieRequest .Request .Cookie = map [string ]string {
8496 "name" : "value" ,
@@ -95,6 +107,12 @@ func TestGenerators(t *testing.T) {
95107 assert .Equal (t , expectedCookieRequestJavaCode , result , result )
96108 })
97109
110+ t .Run ("python cookie HTTP request" , func (t * testing.T ) {
111+ result , err := generator .GetCodeGenerator ("python" ).Generate (nil , cookieRequest )
112+ assert .NoError (t , err )
113+ assert .Equal (t , expectedCookieRequestPythonCode , result , result )
114+ })
115+
98116 bodyRequest := & atest.TestCase {Request : testcase .Request }
99117 bodyRequest .Request .Body .Value = `{"key": "value"}`
100118
@@ -123,5 +141,14 @@ var expectedCookieRequestGoCode string
123141//go:embed testdata/expected_java_cookie_request_code.txt
124142var expectedCookieRequestJavaCode string
125143
144+ //go:embed testdata/expected_python_code.txt
145+ var expectedPythonCode string
146+
147+ //go:embed testdata/expected_python_form_request_code.txt
148+ var expectedFormRequestPythonCode string
149+
150+ //go:embed testdata/expected_python_cookie_request_code.txt
151+ var expectedCookieRequestPythonCode string
152+
126153//go:embed testdata/expected_go_body_request_code.txt
127154var expectedBodyRequestGoCode string
0 commit comments