swagger-api / swagger-api/swagger-codegen
[Python] Generated tests doesn't include required models properties
Open
Nobody has claimed this yet.
Client: Python
help wanted
Issue: Workaround available
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
The generated tests fail when a model has some required properties (e.g. https://travis-ci.org/FlatIO/api-client-python/jobs/249376469)
Swagger-codegen version
master (e50a4cca36)
Swagger declaration file content or url
AssignmentCopy:
description: Assignment copy operation
type: object
required:
- classroom
properties:
classroom:
type: string
description: The destination classroom where the assignment will be copied
Command line used for generation
java -jar swagger-codegen-cli.jar generate -i https://flatio.github.io/api-reference/swagger.yaml -l python -c python-flat.json
{
"packageName": "flat_api",
"packageVersion": "0.3.0",
"packageUrl": "https://github.com/FlatIO/api-client-python"
}
Steps to reproduce
$ nosetests
======================================================================
ERROR: Test AssignmentCopy
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/travis/build/FlatIO/api-client-python/test/test_assignment_copy.py", line 38, in testAssignmentCopy
model = flat_api.models.assignment_copy.AssignmentCopy()
File "/home/travis/build/FlatIO/api-client-python/flat_api/models/assignment_copy.py", line 48, in __init__
self.classroom = classroom
File "/home/travis/build/FlatIO/api-client-python/flat_api/models/assignment_copy.py", line 71, in classroom
raise ValueError("Invalid value for `classroom`, must not be `None`")
ValueError: Invalid value for `classroom`, must not be `None
Related issues
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the supplied generation command and inspect test/test_assignment_copy.py alongside flat_api/models/assignment_copy.py. Compare how generated tests construct models with required properties, then rerun nosetests; done means the generated test suite no longer fails for AssignmentCopy or equivalent required-property models.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100