fix: Apply black formatting to resolve CI formatting issues
This commit is contained in:
@@ -86,7 +86,9 @@ class GoGenerator:
|
||||
|
||||
return generated_files
|
||||
|
||||
def _group_endpoints_by_path(self, endpoints: List[Dict[str, Any]]) -> Dict[str, List[Dict[str, Any]]]:
|
||||
def _group_endpoints_by_path(
|
||||
self, endpoints: List[Dict[str, Any]]
|
||||
) -> Dict[str, List[Dict[str, Any]]]:
|
||||
"""Group endpoints by their path.
|
||||
|
||||
Args:
|
||||
@@ -133,7 +135,7 @@ class GoGenerator:
|
||||
test_name = self._generate_test_name(endpoint)
|
||||
params = self._generate_params(endpoint)
|
||||
|
||||
test_code = f'''
|
||||
test_code = f"""
|
||||
func Test{test_name}(t *testing.T) {{
|
||||
client := &http.Client{{Timeout: 10 * time.Second}}
|
||||
url := baseURL + "{endpoint['path']}"
|
||||
@@ -162,7 +164,7 @@ func Test{test_name}(t *testing.T) {{
|
||||
t.Errorf("Expected status code in [200, 201, 204], got %d", resp.StatusCode)
|
||||
}}
|
||||
}}
|
||||
'''
|
||||
"""
|
||||
return test_code
|
||||
|
||||
def _generate_test_name(self, endpoint: Dict[str, Any]) -> str:
|
||||
@@ -200,7 +202,15 @@ func Test{test_name}(t *testing.T) {{
|
||||
|
||||
if param["in"] == "path":
|
||||
params.append(f'{param_name} := "test_{param_name}"')
|
||||
params.append('url = strings.Replace(url, "' + '{' + param_name + '}' + '", ' + param_name + ', 1)')
|
||||
params.append(
|
||||
'url = strings.Replace(url, "'
|
||||
+ "{"
|
||||
+ param_name
|
||||
+ "}"
|
||||
+ '", '
|
||||
+ param_name
|
||||
+ ", 1)"
|
||||
)
|
||||
|
||||
elif param["in"] == "query":
|
||||
params.append(f'q := url.Values{{{param_name}: []string{{"test"}}}}')
|
||||
@@ -222,6 +232,14 @@ func Test{test_name}(t *testing.T) {{
|
||||
parts = []
|
||||
|
||||
for param in path_params:
|
||||
parts.append('strings.Replace(url, "' + '{' + param['name'] + '}' + '", "test_' + param['name'] + '", 1)')
|
||||
parts.append(
|
||||
'strings.Replace(url, "'
|
||||
+ "{"
|
||||
+ param["name"]
|
||||
+ "}"
|
||||
+ '", "test_'
|
||||
+ param["name"]
|
||||
+ '", 1)'
|
||||
)
|
||||
|
||||
return ""
|
||||
|
||||
@@ -30,7 +30,9 @@ class JestGenerator:
|
||||
self.output_dir = Path(output_dir)
|
||||
self.mock_server_url = mock_server_url
|
||||
self.env = Environment(
|
||||
loader=FileSystemLoader(str(Path(__file__).parent.parent.parent / "templates" / "jest")),
|
||||
loader=FileSystemLoader(
|
||||
str(Path(__file__).parent.parent.parent / "templates" / "jest")
|
||||
),
|
||||
trim_blocks=True,
|
||||
lstrip_blocks=True,
|
||||
)
|
||||
@@ -113,7 +115,7 @@ class JestGenerator:
|
||||
endpoint_path = endpoint["path"]
|
||||
endpoint_method = endpoint["method"]
|
||||
|
||||
test_code = f'''
|
||||
test_code = f"""
|
||||
describe('{describe_name}', () => {{
|
||||
it('should {endpoint_method.upper()} {endpoint_path}', async () => {{
|
||||
const response = await request(baseUrl)
|
||||
@@ -122,7 +124,7 @@ describe('{describe_name}', () => {{
|
||||
expect([200, 201, 204]).toContain(response.status);
|
||||
}});
|
||||
}});
|
||||
'''
|
||||
"""
|
||||
return test_code
|
||||
|
||||
def _generate_test_name(self, endpoint: Dict[str, Any]) -> str:
|
||||
@@ -161,7 +163,7 @@ describe('{describe_name}', () => {{
|
||||
parts.append(f'{param_name}="test_{param_name}"')
|
||||
|
||||
elif param["in"] == "query":
|
||||
parts.append(f'{param_name}')
|
||||
parts.append(f"{param_name}")
|
||||
|
||||
if parts:
|
||||
return ", {" + ", ".join(parts) + "}"
|
||||
|
||||
@@ -30,7 +30,9 @@ class PytestGenerator:
|
||||
self.output_dir = Path(output_dir)
|
||||
self.mock_server_url = mock_server_url
|
||||
self.env = Environment(
|
||||
loader=FileSystemLoader(str(Path(__file__).parent.parent.parent / "templates" / "pytest")),
|
||||
loader=FileSystemLoader(
|
||||
str(Path(__file__).parent.parent.parent / "templates" / "pytest")
|
||||
),
|
||||
trim_blocks=True,
|
||||
lstrip_blocks=True,
|
||||
)
|
||||
@@ -160,7 +162,7 @@ def test_{test_name}(base_url, {params}):
|
||||
params.append(f'{param_name}="test_{param_name}"')
|
||||
|
||||
elif param["in"] == "query":
|
||||
params.append(f'{param_name}=None')
|
||||
params.append(f"{param_name}=None")
|
||||
|
||||
return ", ".join(params)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user