I am having problem with testing of a swagger application in python. The error returned was: ModuleNotFoundError: No module named 'routes.dataservices'
I saw a post which I referred to but is still not working. The only difference I see is that my current python codes are placed in a folder called routes.
swagger.yml
paths:
/leaderboard:
get:
tags:
- Data Services
summary: Get leaderboard
operationId: routes.dataservices.get_leaderboard
responses:
200:
description: Successful
content:
application/json:
schema:
$ref: '#/components/schemas/LeaderList'
400:
description: Retrieval error
content: {}
dataservices.py
def get_leaderboard():
return {'msg': 'ok'}, 200
test_api.py
import pytest
import connexion
flask_app = connexion.FlaskApp(__name__, specification_dir='../specs/')
flask_app.add_api('swagger.yml')
@pytest.fixture(scope='module')
def client():
with flask_app.app.test_client() as c:
yield c
def test_ui(client):
response = client.get('/v0.1/ui')
assert response.status_code == 308
Directory structure
├── main
│ └── routes
│ └── dataservices.py
│ └── specs
│ └── swagger.yml
│ └── tests
│ └── test-api.py