devdox-ai-locust 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of devdox-ai-locust might be problematic. Click here for more details.
- devdox_ai_locust-0.1.1/LICENSE +201 -0
- devdox_ai_locust-0.1.1/PKG-INFO +424 -0
- devdox_ai_locust-0.1.1/README.md +360 -0
- devdox_ai_locust-0.1.1/pyproject.toml +209 -0
- devdox_ai_locust-0.1.1/setup.cfg +4 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust/__init__.py +9 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust/cli.py +452 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust/config.py +24 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust/hybrid_loctus_generator.py +904 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust/locust_generator.py +732 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust/py.typed +0 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust/schemas/__init__.py +0 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust/schemas/processing_result.py +24 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust/templates/base_workflow.py.j2 +180 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust/templates/config.py.j2 +173 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust/templates/custom_flows.py.j2 +95 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust/templates/endpoint_template.py.j2 +34 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust/templates/env.example.j2 +3 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust/templates/fallback_locust.py.j2 +25 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust/templates/locust.py.j2 +70 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust/templates/readme.md.j2 +46 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust/templates/requirement.txt.j2 +31 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust/templates/test_data.py.j2 +276 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust/templates/utils.py.j2 +335 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust/utils/__init__.py +0 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust/utils/file_creation.py +120 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust/utils/open_ai_parser.py +431 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust/utils/swagger_utils.py +94 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust.egg-info/PKG-INFO +424 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust.egg-info/SOURCES.txt +37 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust.egg-info/dependency_links.txt +1 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust.egg-info/entry_points.txt +3 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust.egg-info/requires.txt +43 -0
- devdox_ai_locust-0.1.1/src/devdox_ai_locust.egg-info/top_level.txt +1 -0
- devdox_ai_locust-0.1.1/tests/test_cli.py +606 -0
- devdox_ai_locust-0.1.1/tests/test_config.py +232 -0
- devdox_ai_locust-0.1.1/tests/test_data.py +505 -0
- devdox_ai_locust-0.1.1/tests/test_hybrid_loctus_generator.py +896 -0
- devdox_ai_locust-0.1.1/tests/test_locust_generator.py +671 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: devdox_ai_locust
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: AI-powered Locust load test generator from API documentation
|
|
5
|
+
Author-email: Hayat Bourji <hayat.bourgi@montyholding.com>
|
|
6
|
+
Maintainer-email: Hayat Bourji <hayat.bourgi@montyholding.com>
|
|
7
|
+
License: Apache-2.0
|
|
8
|
+
Project-URL: Homepage, https://github.com/montymobile1/devdox-ai-locust
|
|
9
|
+
Project-URL: Repository, https://github.com/montymobile1/devdox-ai-locust
|
|
10
|
+
Keywords: locust,load-testing,api,testing,performance,ai,openapi,swagger
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Topic :: Software Development :: Testing
|
|
18
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
19
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
|
|
20
|
+
Classifier: Topic :: System :: Networking :: Monitoring
|
|
21
|
+
Requires-Python: >=3.12
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: click>=8.0.0
|
|
25
|
+
Requires-Dist: pyyaml>=6.0
|
|
26
|
+
Requires-Dist: requests>=2.28.0
|
|
27
|
+
Requires-Dist: locust>=2.0.0
|
|
28
|
+
Requires-Dist: faker>=15.0.0
|
|
29
|
+
Requires-Dist: colorama>=0.4.0
|
|
30
|
+
Requires-Dist: rich>=12.0.0
|
|
31
|
+
Requires-Dist: pydantic>=1.10.0
|
|
32
|
+
Requires-Dist: langchain-together==0.3.0
|
|
33
|
+
Requires-Dist: together==1.5.17
|
|
34
|
+
Requires-Dist: jinja2>=3.0.0
|
|
35
|
+
Requires-Dist: black==25.1.0
|
|
36
|
+
Requires-Dist: pydantic-settings==2.10.1
|
|
37
|
+
Provides-Extra: dev
|
|
38
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
39
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
40
|
+
Requires-Dist: black>=22.0; extra == "dev"
|
|
41
|
+
Requires-Dist: flake8>=5.0; extra == "dev"
|
|
42
|
+
Requires-Dist: mypy>=1.0; extra == "dev"
|
|
43
|
+
Requires-Dist: pre-commit>=2.20; extra == "dev"
|
|
44
|
+
Requires-Dist: twine>=4.0; extra == "dev"
|
|
45
|
+
Requires-Dist: build>=0.8; extra == "dev"
|
|
46
|
+
Requires-Dist: ruff==0.13.1; extra == "dev"
|
|
47
|
+
Requires-Dist: types-Pygments==2.19.0.20250809; extra == "dev"
|
|
48
|
+
Provides-Extra: docs
|
|
49
|
+
Requires-Dist: sphinx>=5.0; extra == "docs"
|
|
50
|
+
Requires-Dist: sphinx-rtd-theme>=1.0; extra == "docs"
|
|
51
|
+
Requires-Dist: myst-parser>=0.18; extra == "docs"
|
|
52
|
+
Provides-Extra: test
|
|
53
|
+
Requires-Dist: pytest>=7.0; extra == "test"
|
|
54
|
+
Requires-Dist: pytest-cov>=4.0; extra == "test"
|
|
55
|
+
Requires-Dist: pytest-mock>=3.8; extra == "test"
|
|
56
|
+
Requires-Dist: pytest-asyncio>=0.21; extra == "test"
|
|
57
|
+
Requires-Dist: httpx>=0.23; extra == "test"
|
|
58
|
+
Requires-Dist: aiofiles>=23.0; extra == "test"
|
|
59
|
+
Requires-Dist: coverage>=7.0; extra == "test"
|
|
60
|
+
Provides-Extra: ai
|
|
61
|
+
Requires-Dist: openai>=0.27.0; extra == "ai"
|
|
62
|
+
Requires-Dist: anthropic>=0.3.0; extra == "ai"
|
|
63
|
+
Dynamic: license-file
|
|
64
|
+
|
|
65
|
+
# DevDox AI Locust
|
|
66
|
+
|
|
67
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
68
|
+
[](https://www.python.org/downloads/)
|
|
69
|
+
[](https://github.com/psf/black)
|
|
70
|
+
|
|
71
|
+
> **AI-powered Locust load test generator from API documentation**
|
|
72
|
+
|
|
73
|
+
DevDox AI Locust automatically generates comprehensive Locust load testing scripts from your API documentation (OpenAPI/Swagger specs). Using advanced AI capabilities, it creates realistic test scenarios, handles complex authentication flows, and generates production-ready performance tests.
|
|
74
|
+
|
|
75
|
+
## ✨ Features
|
|
76
|
+
|
|
77
|
+
- 🤖 **AI-Enhanced Generation**: Uses Together AI to create intelligent, realistic load test scenarios
|
|
78
|
+
- 📚 **OpenAPI/Swagger Support**: Automatically parses OpenAPI 3.0 and Swagger 2.0 specifications
|
|
79
|
+
- 🔧 **Production-Ready Code**: Generates clean, maintainable Locust test files
|
|
80
|
+
- 🎯 **Smart Test Scenarios**: Creates CRUD workflows, authentication flows, and error handling
|
|
81
|
+
- 📊 **Realistic Data**: Generates appropriate test data using Faker
|
|
82
|
+
- 🛠️ **Template-Based**: Highly customizable Jinja2 templates for different testing needs
|
|
83
|
+
- 🔄 **Hybrid Approach**: Combines rule-based generation with AI enhancement
|
|
84
|
+
- 📈 **Comprehensive Coverage**: Handles various HTTP methods, content types, and response scenarios
|
|
85
|
+
|
|
86
|
+
## 🚀 Quick Start
|
|
87
|
+
|
|
88
|
+
### Installation
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Install from PyPI (when published)
|
|
92
|
+
pip install devdox-ai-locust
|
|
93
|
+
|
|
94
|
+
# Or install from source
|
|
95
|
+
git clone https://github.com/montymobile1/devdox-ai-locust.git
|
|
96
|
+
cd devdox-ai-locust
|
|
97
|
+
pip install -e .
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Prerequisites
|
|
101
|
+
|
|
102
|
+
1. **Python 3.12+** - Required for modern async/await syntax and type hints
|
|
103
|
+
2. **Together AI API Key** - For AI-enhanced generation capabilities
|
|
104
|
+
|
|
105
|
+
### Configuration
|
|
106
|
+
|
|
107
|
+
1. Get your Together AI API key from [Together AI](https://api.together.xyz/)
|
|
108
|
+
2. Set up your environment:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Copy example environment file
|
|
112
|
+
cp .env.example .env
|
|
113
|
+
|
|
114
|
+
# Edit .env and add your API key
|
|
115
|
+
echo "API_KEY=your_together_ai_api_key_here" > .env
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Basic Usage
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Generate from OpenAPI URL
|
|
122
|
+
devdox_ai_locust generate --openapi-url https://api.example.com/openapi.json --output ./tests
|
|
123
|
+
|
|
124
|
+
# Generate from local file
|
|
125
|
+
dal generate --openapi-file ./api-spec.yaml --output ./load-tests
|
|
126
|
+
|
|
127
|
+
# Generate with custom configuration
|
|
128
|
+
devdox_ai_locust generate \
|
|
129
|
+
https://petstore.swagger.io/v2/swagger.json \
|
|
130
|
+
--output ./petstore-tests \
|
|
131
|
+
--together-api-key your_api_key \
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
## 📖 Documentation
|
|
138
|
+
|
|
139
|
+
### Command Line Interface
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
devdox_ai_locust generate [OPTIONS] SWAGGER_URL
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
| Option | Short | Type | Description | Default |
|
|
146
|
+
|--------|--------|------|-------------|---------|
|
|
147
|
+
| `--output` | `-o` | Path | Output directory for generated tests | `output` |
|
|
148
|
+
| `--users` | `-u` | Integer | Number of simulated users | `10` |
|
|
149
|
+
| `--spawn-rate` | `-r` | Float | User spawn rate (users/second) | `2` |
|
|
150
|
+
| `--run-time` | `-t` | String | Test duration (e.g., 5m, 1h) | `5m` |
|
|
151
|
+
| `--host` | `-H` | String | Target host URL | None |
|
|
152
|
+
| `--auth/--no-auth` | | Boolean | Include authentication | `True` |
|
|
153
|
+
| `--dry-run` | | Flag | Generate without running | `False` |
|
|
154
|
+
| `--custom-requirement` | | String | Custom AI instructions | None |
|
|
155
|
+
| `--together-api-key` | | String | Together AI API key | From env |
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
### Generated Test Structure
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
locust_tests/
|
|
164
|
+
├── locust.py # Main Locust test file
|
|
165
|
+
├── config.py # Test configuration
|
|
166
|
+
├── test_data.py # Test data generators
|
|
167
|
+
├── utils.py # Utility functions
|
|
168
|
+
├── requirements.txt # Python dependencies
|
|
169
|
+
├── .env.example # Environment variables template
|
|
170
|
+
├── README.md # Test documentation
|
|
171
|
+
├── workflows/
|
|
172
|
+
│ ├── user_workflow.py # User-related test scenarios
|
|
173
|
+
│ ├── auth_workflow.py # Authentication workflows
|
|
174
|
+
│ └── crud_workflow.py # CRUD operation workflows
|
|
175
|
+
└── data/
|
|
176
|
+
├── users.json # Sample user data
|
|
177
|
+
└── test_cases.json # Predefined test cases
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## 🔧 Advanced Usage
|
|
181
|
+
|
|
182
|
+
### Custom Templates
|
|
183
|
+
|
|
184
|
+
Create custom Jinja2 templates for specialized test generation:
|
|
185
|
+
|
|
186
|
+
```python
|
|
187
|
+
# custom_template.py.j2
|
|
188
|
+
from locust import HttpUser, task, between
|
|
189
|
+
|
|
190
|
+
class {{ class_name }}User(HttpUser):
|
|
191
|
+
wait_time = between(1, 3)
|
|
192
|
+
|
|
193
|
+
def on_start(self):
|
|
194
|
+
"""Setup method called before tasks"""
|
|
195
|
+
self.token = self.login()
|
|
196
|
+
|
|
197
|
+
{% for endpoint in endpoints %}
|
|
198
|
+
@task({{ endpoint.weight | default(1) }})
|
|
199
|
+
def {{ endpoint.method_name }}(self):
|
|
200
|
+
"""{{ endpoint.description }}"""
|
|
201
|
+
# Custom task implementation
|
|
202
|
+
{{ endpoint.ai_generated_code | indent(8) }}
|
|
203
|
+
{% endfor %}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Programmatic Usage
|
|
207
|
+
|
|
208
|
+
```python
|
|
209
|
+
from devdox_ai_locust import HybridLocustGenerator
|
|
210
|
+
from devdox_ai_locust.config import Settings
|
|
211
|
+
|
|
212
|
+
# Initialize generator
|
|
213
|
+
config = Settings()
|
|
214
|
+
generator = HybridLocustGenerator(config)
|
|
215
|
+
|
|
216
|
+
# Generate from OpenAPI spec
|
|
217
|
+
async def generate_tests():
|
|
218
|
+
files, workflows = await generator.generate_from_url(
|
|
219
|
+
"https://api.example.com/openapi.json",
|
|
220
|
+
output_dir="./tests",
|
|
221
|
+
ai_enhanced=True
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
print(f"Generated {len(files)} test files")
|
|
225
|
+
print(f"Created {len(workflows)} workflows")
|
|
226
|
+
|
|
227
|
+
# Run generation
|
|
228
|
+
import asyncio
|
|
229
|
+
asyncio.run(generate_tests())
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
## 🧪 Development
|
|
234
|
+
|
|
235
|
+
### Setup Development Environment
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
# Clone repository
|
|
239
|
+
git clone https://github.com/montymobile1/devdox-ai-locust.git
|
|
240
|
+
cd devdox-ai-locust
|
|
241
|
+
|
|
242
|
+
# Create virtual environment
|
|
243
|
+
python -m venv venv
|
|
244
|
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
245
|
+
|
|
246
|
+
# Install in development mode
|
|
247
|
+
pip install -e ".[dev,test,ai]"
|
|
248
|
+
|
|
249
|
+
# Install pre-commit hooks
|
|
250
|
+
pre-commit install
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Running Tests
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
|
|
257
|
+
# Use the test runner script
|
|
258
|
+
coverage run -m pytest tests/
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
### Project Structure
|
|
264
|
+
|
|
265
|
+
```
|
|
266
|
+
src/devdox_ai_locust/
|
|
267
|
+
├── __init__.py
|
|
268
|
+
├── cli.py # Command line interface
|
|
269
|
+
├── config.py # Configuration management
|
|
270
|
+
├── locust_generator.py # Basic test generation
|
|
271
|
+
├── hybrid_loctus_generator.py # AI-enhanced generation
|
|
272
|
+
├── templates/ # Jinja2 templates
|
|
273
|
+
│ ├── locust.py.j2
|
|
274
|
+
│ ├── config.py.j2
|
|
275
|
+
│ └── workflow.py.j2
|
|
276
|
+
├── schemas/ # Data models and validation
|
|
277
|
+
│ ├── processing_result.py
|
|
278
|
+
│ └── endpoint_schema.py
|
|
279
|
+
├── utils/ # Utility modules
|
|
280
|
+
│ ├── swagger_utils.py
|
|
281
|
+
│ ├── open_ai_parser.py
|
|
282
|
+
│ └── file_creation.py
|
|
283
|
+
└── prompt/ # AI prompt templates
|
|
284
|
+
├── system_prompts.py
|
|
285
|
+
└── enhancement_prompts.py
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Development Workflow
|
|
289
|
+
|
|
290
|
+
1. **Fork** the repository
|
|
291
|
+
2. **Create** a feature branch (`git checkout -b feature/amazing-feature`)
|
|
292
|
+
3. **Make** your changes
|
|
293
|
+
4. **Add** tests for new functionality
|
|
294
|
+
5. **Run** the test suite (`make test`)
|
|
295
|
+
6. **Commit** your changes (`git commit -m 'Add amazing feature'`)
|
|
296
|
+
7. **Push** to the branch (`git push origin feature/amazing-feature`)
|
|
297
|
+
8. **Open** a Pull Request
|
|
298
|
+
|
|
299
|
+
### Code Standards
|
|
300
|
+
|
|
301
|
+
- **Python 3.12+** with type hints
|
|
302
|
+
- **Black** for code formatting
|
|
303
|
+
- **isort** for import sorting
|
|
304
|
+
- **pytest** for testing
|
|
305
|
+
- **mypy** for type checking
|
|
306
|
+
- **Pre-commit hooks** for quality gates
|
|
307
|
+
|
|
308
|
+
## 📋 Requirements
|
|
309
|
+
|
|
310
|
+
### System Requirements
|
|
311
|
+
|
|
312
|
+
- **Python**: 3.12 or higher
|
|
313
|
+
- **Memory**: 512MB RAM minimum, 1GB recommended
|
|
314
|
+
- **Storage**: 100MB for installation, additional space for generated tests
|
|
315
|
+
|
|
316
|
+
### Dependencies
|
|
317
|
+
|
|
318
|
+
#### Core Dependencies
|
|
319
|
+
- `locust` - Load testing framework
|
|
320
|
+
- `click` - CLI framework
|
|
321
|
+
- `pyyaml` - YAML parsing
|
|
322
|
+
- `requests` - HTTP client
|
|
323
|
+
- `pydantic` - Data validation
|
|
324
|
+
- `jinja2` - Template engine
|
|
325
|
+
- `rich` - Rich text output
|
|
326
|
+
- `faker` - Test data generation
|
|
327
|
+
|
|
328
|
+
#### AI Dependencies
|
|
329
|
+
- `langchain-together` - Together AI integration
|
|
330
|
+
- `together` - Together AI Python client
|
|
331
|
+
|
|
332
|
+
#### Development Dependencies
|
|
333
|
+
- `pytest` - Testing framework
|
|
334
|
+
- `black` - Code formatter
|
|
335
|
+
- `mypy` - Type checker
|
|
336
|
+
- `pre-commit` - Git hooks
|
|
337
|
+
|
|
338
|
+
## 🔍 Examples
|
|
339
|
+
|
|
340
|
+
### Example 1: E-commerce API
|
|
341
|
+
|
|
342
|
+
```bash
|
|
343
|
+
# Generate tests for an e-commerce API
|
|
344
|
+
devdox_ai_locust generate \
|
|
345
|
+
https://api.shop.example.com/v1/openapi.json \
|
|
346
|
+
--output ./ecommerce-tests
|
|
347
|
+
|
|
348
|
+
# The generator will create:
|
|
349
|
+
# - Product browsing scenarios
|
|
350
|
+
# - Shopping cart workflows
|
|
351
|
+
# - Checkout and payment flows
|
|
352
|
+
# - User registration and login
|
|
353
|
+
# - Order management tests
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
## ❓ FAQ
|
|
357
|
+
|
|
358
|
+
**Q: What API specification formats are supported?**
|
|
359
|
+
A: We support OpenAPI 3.0+ and Swagger 2.0 specifications in JSON and YAML formats.
|
|
360
|
+
|
|
361
|
+
**Q: Do I need an AI API key?**
|
|
362
|
+
A: Yes, for AI-enhanced generation you need a Together AI API key. Basic generation works without AI.
|
|
363
|
+
|
|
364
|
+
**Q: Can I customize the generated test templates?**
|
|
365
|
+
A: Absolutely! You can provide custom Jinja2 templates using the `--template-dir` option.
|
|
366
|
+
|
|
367
|
+
**Q: How do I handle authentication in generated tests?**
|
|
368
|
+
A: The generator automatically detects authentication schemes from your OpenAPI spec and creates appropriate test flows.
|
|
369
|
+
|
|
370
|
+
**Q: Can I run tests against different environments?**
|
|
371
|
+
A: Yes, use environment variables or configuration files to specify different target hosts and settings.
|
|
372
|
+
|
|
373
|
+
**Q: What if my API has complex business logic?**
|
|
374
|
+
A: The AI enhancement feature analyzes your API patterns and generates realistic business workflows, not just individual endpoint tests.
|
|
375
|
+
|
|
376
|
+
## 🐛 Troubleshooting
|
|
377
|
+
|
|
378
|
+
### Common Issues
|
|
379
|
+
|
|
380
|
+
**Import Errors**
|
|
381
|
+
```bash
|
|
382
|
+
# Ensure proper installation
|
|
383
|
+
pip install -e .
|
|
384
|
+
|
|
385
|
+
# Check Python path
|
|
386
|
+
python -c "import devdox_ai_locust; print('OK')"
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
**API Key Issues**
|
|
390
|
+
```bash
|
|
391
|
+
# Verify API key is set
|
|
392
|
+
echo $API_KEY
|
|
393
|
+
|
|
394
|
+
# Test API connectivity
|
|
395
|
+
python -c "from together import Together; print(Together(api_key='your_key').models.list())"
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
**Template Errors**
|
|
400
|
+
```bash
|
|
401
|
+
# Validate your OpenAPI spec
|
|
402
|
+
# Use online validators like swagger.io/tools/swagger-editor/
|
|
403
|
+
|
|
404
|
+
# Check template syntax
|
|
405
|
+
# Ensure custom templates use valid Jinja2 syntax
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
## 📄 License
|
|
409
|
+
|
|
410
|
+
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
|
|
411
|
+
|
|
412
|
+
## 🙏 Acknowledgments
|
|
413
|
+
|
|
414
|
+
- **Locust** - The amazing load testing framework that powers our generated tests
|
|
415
|
+
- **Together AI** - Providing the AI capabilities for intelligent test generation
|
|
416
|
+
- **OpenAPI Initiative** - For standardizing API documentation
|
|
417
|
+
- **Python Community** - For the excellent libraries and tools
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
---
|
|
421
|
+
|
|
422
|
+
**Made with ❤️ by the DevDox team**
|
|
423
|
+
|
|
424
|
+
Transform your API documentation into powerful load tests with the magic of AI! 🚀
|