devdox-ai-locust 0.1.3.post1__py3-none-any.whl → 0.1.4__py3-none-any.whl
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/cli.py +19 -3
- devdox_ai_locust/config.py +1 -1
- devdox_ai_locust/hybrid_loctus_generator.py +37 -8
- devdox_ai_locust/locust_generator.py +84 -9
- devdox_ai_locust/prompt/test_data.j2 +152 -28
- devdox_ai_locust/prompt/workflow.j2 +349 -11
- devdox_ai_locust/templates/mongo/data_provider.py.j2 +303 -0
- devdox_ai_locust/templates/mongo/db_config.py.j2 +271 -0
- devdox_ai_locust/templates/mongo/db_integration.j2 +352 -0
- devdox_ai_locust/templates/readme.md.j2 +3 -1
- devdox_ai_locust/templates/requirement.txt.j2 +5 -2
- devdox_ai_locust/templates/test_data.py.j2 +5 -1
- {devdox_ai_locust-0.1.3.post1.dist-info → devdox_ai_locust-0.1.4.dist-info}/METADATA +26 -11
- {devdox_ai_locust-0.1.3.post1.dist-info → devdox_ai_locust-0.1.4.dist-info}/RECORD +18 -15
- {devdox_ai_locust-0.1.3.post1.dist-info → devdox_ai_locust-0.1.4.dist-info}/WHEEL +0 -0
- {devdox_ai_locust-0.1.3.post1.dist-info → devdox_ai_locust-0.1.4.dist-info}/entry_points.txt +0 -0
- {devdox_ai_locust-0.1.3.post1.dist-info → devdox_ai_locust-0.1.4.dist-info}/licenses/LICENSE +0 -0
- {devdox_ai_locust-0.1.3.post1.dist-info → devdox_ai_locust-0.1.4.dist-info}/top_level.txt +0 -0
|
@@ -32,6 +32,70 @@ CRITICAL CONSTRAINTS: Only use endpoints that exist in the OpenAPI specification
|
|
|
32
32
|
- ADD cleanup methods for created resources
|
|
33
33
|
- ADD data correlation between sequential tasks
|
|
34
34
|
|
|
35
|
+
{% if db_type=="mongo" %}
|
|
36
|
+
7. DATABASE DATA HANDLING AND CRUD OPERATIONS:
|
|
37
|
+
|
|
38
|
+
- Check if db_type == "mongo" in the configuration
|
|
39
|
+
- If MongoDB is enabled (mongo_config.enable_mongodb):
|
|
40
|
+
ADD proper MongoDB import handling with graceful fallback:
|
|
41
|
+
```python
|
|
42
|
+
try:
|
|
43
|
+
from data_provider import mongo_data_provider
|
|
44
|
+
MONGODB_ENABLED = True
|
|
45
|
+
except ImportError:
|
|
46
|
+
MONGODB_ENABLED = False
|
|
47
|
+
mongo_data_provider = None
|
|
48
|
+
```
|
|
49
|
+
- If MongoDB is enabled (MONGODB_ENABLED and getattr(config, 'enable_mongodb', False)):
|
|
50
|
+
* Use mongo_data_provider.get_document() for single document retrieval
|
|
51
|
+
* Use mongo_data_provider.get_multiple_documents() for multiple document retrieval
|
|
52
|
+
* Integrate MongoDB data into workflow tasks where appropriate
|
|
53
|
+
* Store MongoDB document IDs for use in subsequent API calls
|
|
54
|
+
* ADD MongoDB-specific test data patterns
|
|
55
|
+
* ADD MongoDB document validation in API requests
|
|
56
|
+
* ADD MongoDB collection-based test scenarios
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
8. DUAL DATA SOURCE CAPABILITY:
|
|
60
|
+
- ADD configuration option to choose between generated data vs real database data
|
|
61
|
+
|
|
62
|
+
- ADD method to switch between data sources: use_generated_data() vs use_database_data()
|
|
63
|
+
|
|
64
|
+
- ADD CRUD operation support for real database testing:
|
|
65
|
+
|
|
66
|
+
* CREATE: Insert test records into database before API testing
|
|
67
|
+
|
|
68
|
+
* READ: Retrieve existing data from database for API operations
|
|
69
|
+
|
|
70
|
+
* UPDATE: Modify database records and test API consistency
|
|
71
|
+
|
|
72
|
+
* DELETE: Remove test data and verify API responses
|
|
73
|
+
|
|
74
|
+
- ADD data validation between database state and API responses
|
|
75
|
+
|
|
76
|
+
- ADD rollback capabilities for database operations
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
9. MONGODB INTEGRATION PATTERNS:
|
|
80
|
+
- Import mongo_data_provider at the top of the workflow file
|
|
81
|
+
- ADD MongoDB data retrieval in on_start() method if needed
|
|
82
|
+
- Use MongoDB documents as test data for API endpoints
|
|
83
|
+
- ADD correlation between MongoDB documents and API responses
|
|
84
|
+
- ADD MongoDB document cleanup in on_stop() method
|
|
85
|
+
- ADD database transaction support for complex test scenarios
|
|
86
|
+
- ADD data consistency validation between database and API
|
|
87
|
+
|
|
88
|
+
10. CRUD-BASED WORKFLOW ENHANCEMENTS:
|
|
89
|
+
|
|
90
|
+
- ADD database setup/teardown methods for each test scenario
|
|
91
|
+
- ADD real data validation against API endpoints
|
|
92
|
+
- ADD database state verification after API operations
|
|
93
|
+
- ADD conflict resolution for concurrent database operations
|
|
94
|
+
- ADD data integrity checks throughout the workflow
|
|
95
|
+
|
|
96
|
+
{% endif %}
|
|
97
|
+
|
|
98
|
+
|
|
35
99
|
|
|
36
100
|
CURRENT WORKFLOW FILE:
|
|
37
101
|
{{base_content}}
|
|
@@ -58,6 +122,7 @@ CRITICAL CONSTRAINTS: Only use endpoints that exist in the OpenAPI specification
|
|
|
58
122
|
- Pass generated data between related API calls
|
|
59
123
|
|
|
60
124
|
- Maintain state between sequential tasks for realistic workflows
|
|
125
|
+
{% if db_type=="mongo" %} - If MongoDB is enabled, correlate MongoDB document data with API operations {% endif %}
|
|
61
126
|
|
|
62
127
|
3. Fix indentation issues
|
|
63
128
|
|
|
@@ -67,6 +132,7 @@ CRITICAL CONSTRAINTS: Only use endpoints that exist in the OpenAPI specification
|
|
|
67
132
|
- New functions to add to test_data.py
|
|
68
133
|
- New example patterns to add to example.py
|
|
69
134
|
- New data generators for specific ID requirements
|
|
135
|
+
{% if db_type=="mongo" %} - MongoDB-specific data retrieval patterns if db_type == "mongo" {% endif %}
|
|
70
136
|
|
|
71
137
|
|
|
72
138
|
|
|
@@ -81,34 +147,78 @@ CRITICAL CONSTRAINTS: Only use endpoints that exist in the OpenAPI specification
|
|
|
81
147
|
9. Add data cleanup on stop for resources created during testing
|
|
82
148
|
|
|
83
149
|
10. Improve data parameterization using available test data generators
|
|
150
|
+
{% if db_type=="mongo" %} 11. **MONGODB SPECIFIC ENHANCEMENTS** ( mongo_config.enable_mongodb):
|
|
151
|
+
|
|
152
|
+
- ADD MongoDB document retrieval for realistic test data
|
|
153
|
+
|
|
154
|
+
- ADD MongoDB document IDs to API request parameters
|
|
155
|
+
|
|
156
|
+
- ADD validation that API responses match MongoDB document structure
|
|
157
|
+
|
|
158
|
+
- ADD MongoDB-based test scenarios that reflect real data usage patterns
|
|
159
|
+
|
|
160
|
+
- ADD CRUD operations for comprehensive database testing:
|
|
161
|
+
|
|
162
|
+
* **CREATE**: Insert new documents via database, test API retrieval
|
|
163
|
+
|
|
164
|
+
* **READ**: Query existing documents, validate API consistency
|
|
165
|
+
|
|
166
|
+
* **UPDATE**: Modify documents via database, test API reflects changes
|
|
167
|
+
|
|
168
|
+
* **DELETE**: Remove documents via database, test API handles missing data
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
**C. Hybrid Mode**:
|
|
173
|
+
|
|
174
|
+
- ADD capability to use both generated and real data in same workflow
|
|
175
|
+
|
|
176
|
+
- ADD data source switching based on test scenario requirements
|
|
177
|
+
|
|
178
|
+
- ADD validation between generated and real data patterns{% endif %}
|
|
84
179
|
|
|
85
180
|
|
|
86
181
|
|
|
87
182
|
LOGICAL TASK SEQUENCE EXAMPLE:
|
|
88
183
|
|
|
89
184
|
For reseller workflow, the logical order should be:
|
|
185
|
+
{% if db_type=="mongo" %}
|
|
186
|
+
- **MongoDB Data Setup** (if enabled):
|
|
90
187
|
|
|
91
|
-
|
|
188
|
+
- Retrieve MongoDB documents for test data
|
|
92
189
|
|
|
93
|
-
|
|
190
|
+
- Store document IDs for API operations
|
|
94
191
|
|
|
95
|
-
|
|
192
|
+
{% endif %}
|
|
96
193
|
|
|
97
|
-
|
|
194
|
+
- add_reseller (create) → store reseller_id
|
|
98
195
|
|
|
99
|
-
|
|
196
|
+
- get_reseller (list/search)
|
|
100
197
|
|
|
101
|
-
|
|
198
|
+
- get_reseller_by_id (using stored reseller_id)
|
|
102
199
|
|
|
103
|
-
|
|
200
|
+
- available_reseller_properties (using reseller_id)
|
|
104
201
|
|
|
105
|
-
|
|
202
|
+
- customize_corporate_price (using reseller_id)
|
|
106
203
|
|
|
107
|
-
|
|
204
|
+
- customize_corporate_price_csv (using reseller_id)
|
|
108
205
|
|
|
109
|
-
|
|
206
|
+
- customize_price (using reseller_id)
|
|
207
|
+
|
|
208
|
+
- customize_price_csv (using reseller_id)
|
|
209
|
+
|
|
210
|
+
- topup_reseller_balance (using reseller_id)
|
|
211
|
+
|
|
212
|
+
- edit_reseller (using reseller_id)
|
|
213
|
+
|
|
214
|
+
- delete_reseller (cleanup using reseller_id)
|
|
215
|
+
|
|
216
|
+
{% if db_type=="mongo" %}
|
|
217
|
+
- **MongoDB Cleanup** (if enabled):
|
|
218
|
+
|
|
219
|
+
- Clean up any test documents created during workflow
|
|
220
|
+
{% endif %}
|
|
110
221
|
|
|
111
|
-
11. delete_reseller (cleanup using reseller_id)
|
|
112
222
|
|
|
113
223
|
VALIDATION RULES:
|
|
114
224
|
- Every @task method must correspond to an actual OpenAPI endpoint
|
|
@@ -117,6 +227,9 @@ VALIDATION RULES:
|
|
|
117
227
|
- Use only test_data.py functions that exist or suggest new ones to ADD
|
|
118
228
|
- Ensure realistic user workflows with proper data dependencies
|
|
119
229
|
- ADD error handling and resource cleanup
|
|
230
|
+
{% if db_type=="mongo" %}
|
|
231
|
+
- If MongoDB is enabled, ensure proper integration with mongo_data_provider methods
|
|
232
|
+
{% endif %}
|
|
120
233
|
|
|
121
234
|
SUGGESTIONS FOR ADDITIONS (if needed):
|
|
122
235
|
If the workflow needs new test data generators or example patterns,
|
|
@@ -129,6 +242,231 @@ VALIDATION RULES:
|
|
|
129
242
|
# New function for ID-dependent APIs
|
|
130
243
|
pass
|
|
131
244
|
```
|
|
245
|
+
{% if db_type=="mongo" %}
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
# MongoDB-specific additions (if db_type == "mongo")
|
|
249
|
+
|
|
250
|
+
def get_mongodb_test_data(collection_name, filter_criteria=None):
|
|
251
|
+
|
|
252
|
+
# Function to integrate MongoDB data
|
|
253
|
+
|
|
254
|
+
if mongo_config.enable_mongodb:
|
|
255
|
+
|
|
256
|
+
if filter_criteria:
|
|
257
|
+
|
|
258
|
+
return mongo_data_provider.get_document(collection_name, filter_criteria)
|
|
259
|
+
|
|
260
|
+
else:
|
|
261
|
+
|
|
262
|
+
return mongo_data_provider.get_multiple_documents(collection_name, {})
|
|
263
|
+
|
|
264
|
+
return default_test_data()
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
# CRUD operation helpers
|
|
269
|
+
|
|
270
|
+
def create_test_document(collection_name, document_data):
|
|
271
|
+
|
|
272
|
+
# Create test document in database
|
|
273
|
+
|
|
274
|
+
if mongo_config.enable_mongodb:
|
|
275
|
+
|
|
276
|
+
return mongo_data_provider.insert_document(collection_name, document_data)
|
|
277
|
+
|
|
278
|
+
return None
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
def cleanup_test_documents(collection_name, test_ids):
|
|
283
|
+
|
|
284
|
+
# Clean up test documents
|
|
285
|
+
|
|
286
|
+
if mongo_config.enable_mongodb:
|
|
287
|
+
|
|
288
|
+
return mongo_data_provider.delete_documents(collection_name, {"_id": {"$in": test_ids}})
|
|
289
|
+
|
|
290
|
+
return None
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
# Data source selection
|
|
295
|
+
|
|
296
|
+
def get_test_data(use_database=False, collection_name=None):
|
|
297
|
+
|
|
298
|
+
# Choose between generated and database data
|
|
299
|
+
|
|
300
|
+
if use_database and mongo_config.enable_mongodb and collection_name:
|
|
301
|
+
|
|
302
|
+
return get_mongodb_test_data(collection_name)
|
|
303
|
+
|
|
304
|
+
else:
|
|
305
|
+
|
|
306
|
+
return generate_synthetic_data()
|
|
307
|
+
|
|
308
|
+
# Database example patterns (if db_type == "mongo")
|
|
309
|
+
|
|
310
|
+
def example_mongodb_crud_workflow():
|
|
311
|
+
|
|
312
|
+
# Example showing MongoDB CRUD integration
|
|
313
|
+
|
|
314
|
+
if mongo_config.enable_mongodb:
|
|
315
|
+
|
|
316
|
+
# CREATE: Insert test document
|
|
317
|
+
|
|
318
|
+
test_doc = create_test_document("pets", {"name": "test_pet", "status": "available"})
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
# READ: Retrieve and validate
|
|
323
|
+
|
|
324
|
+
retrieved_doc = mongo_data_provider.get_document("pets", {"_id": test_doc["_id"]})
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
# UPDATE: Modify document
|
|
329
|
+
|
|
330
|
+
mongo_data_provider.update_document("pets", {"_id": test_doc["_id"]}, {"status": "sold"})
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
# DELETE: Remove document
|
|
335
|
+
|
|
336
|
+
mongo_data_provider.delete_document("pets", {"_id": test_doc["_id"]})
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
def example_hybrid_workflow():
|
|
341
|
+
|
|
342
|
+
# Example showing both generated and database data
|
|
343
|
+
|
|
344
|
+
# Use generated data for edge cases
|
|
345
|
+
|
|
346
|
+
generated_data = generate_synthetic_data()
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
# Use database data for realistic scenarios
|
|
351
|
+
|
|
352
|
+
if mongo_config.enable_mongodb:
|
|
353
|
+
|
|
354
|
+
real_data = get_mongodb_test_data("pets")
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
# Combine both for comprehensive testing
|
|
359
|
+
|
|
360
|
+
return {"generated": generated_data, "real": real_data}
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
def example_api_database_consistency():
|
|
365
|
+
|
|
366
|
+
# Example showing API-database consistency validation
|
|
367
|
+
|
|
368
|
+
# 1. Create via API
|
|
369
|
+
|
|
370
|
+
api_response = create_pet_via_api(pet_data)
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
# 2. Verify in database
|
|
375
|
+
|
|
376
|
+
if mongo_config.enable_mongodb:
|
|
377
|
+
|
|
378
|
+
db_document = mongo_data_provider.get_document("pets", {"api_id": api_response["id"]})
|
|
379
|
+
|
|
380
|
+
assert db_document is not None, "Pet not found in database after API creation"
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
# 3. Update via database
|
|
385
|
+
|
|
386
|
+
if mongo_config.enable_mongodb:
|
|
387
|
+
|
|
388
|
+
mongo_data_provider.update_document("pets", {"api_id": api_response["id"]}, {"status": "updated"})
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
# 4. Verify via API
|
|
393
|
+
|
|
394
|
+
updated_pet = get_pet_via_api(api_response["id"])
|
|
395
|
+
|
|
396
|
+
assert updated_pet["status"] == "updated", "API doesn't reflect database changes"
|
|
397
|
+
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
base_workflow.py additions:
|
|
403
|
+
|
|
404
|
+
```python
|
|
405
|
+
|
|
406
|
+
# ADD to BaseTaskMethods class
|
|
407
|
+
|
|
408
|
+
class BaseTaskMethods:
|
|
409
|
+
|
|
410
|
+
def __init__(self):
|
|
411
|
+
|
|
412
|
+
self.use_database_data = mongo_config.enable_mongodb if 'mongo_config' in globals() else False
|
|
413
|
+
|
|
414
|
+
self.test_document_ids = [] # Track created test documents
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
def setup_data_source(self, prefer_database=True):
|
|
419
|
+
|
|
420
|
+
# Configure data source preference
|
|
421
|
+
|
|
422
|
+
self.use_database_data = prefer_database and mongo_config.enable_mongodb
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
def get_test_data(self, data_type, collection_name=None):
|
|
427
|
+
|
|
428
|
+
# Universal data retrieval method
|
|
429
|
+
|
|
430
|
+
if self.use_database_data and collection_name:
|
|
431
|
+
|
|
432
|
+
return get_mongodb_test_data(collection_name)
|
|
433
|
+
|
|
434
|
+
else:
|
|
435
|
+
|
|
436
|
+
return data_generator.generate_data(data_type)
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
def create_test_document(self, collection_name, document_data):
|
|
441
|
+
|
|
442
|
+
# Create test document and track for cleanup
|
|
443
|
+
|
|
444
|
+
if self.use_database_data:
|
|
445
|
+
|
|
446
|
+
doc_id = create_test_document(collection_name, document_data)
|
|
447
|
+
|
|
448
|
+
if doc_id:
|
|
449
|
+
|
|
450
|
+
self.test_document_ids.append(doc_id)
|
|
451
|
+
|
|
452
|
+
return doc_id
|
|
453
|
+
|
|
454
|
+
return None
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
def cleanup_test_data(self):
|
|
459
|
+
|
|
460
|
+
# Clean up any test documents created
|
|
461
|
+
|
|
462
|
+
if self.use_database_data and self.test_document_ids:
|
|
463
|
+
|
|
464
|
+
cleanup_test_documents("test_collection", self.test_document_ids)
|
|
465
|
+
|
|
466
|
+
self.test_document_ids.clear()
|
|
467
|
+
|
|
468
|
+
```
|
|
469
|
+
{% endif %}
|
|
132
470
|
|
|
133
471
|
example.py additions:
|
|
134
472
|
```python
|