Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import unittest
from itertools import chain
from operator import itemgetter
from itertools import (
chain,
)
from operator import (
itemgetter,
)

from minos.common import (
MinosConfig,
)
from minos.networks import EnrouteAnalyzer
from minos.networks import (
EnrouteAnalyzer,
)
from tests.utils import (
BASE_PATH,
)
Expand Down Expand Up @@ -34,46 +40,26 @@ def test_openapi(self):
"version": "1.0.0",
"title": "Minos OpenAPI Spec",
"description": "An example API",
"contact": {
"name": "Minos framework"
},
"license": {
"name": "MIT"
}
"contact": {"name": "Minos framework"},
"license": {"name": "MIT"},
},
"host": "TODO",
"basePath": "/api/specs/openapi",
"schemes": [
"http"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"schemes": ["http"],
"consumes": ["application/json"],
"produces": ["application/json"],
"paths": {},
"definitions": {
"Pet": {
"type": "object",
"required": [
"id",
"name"
],
"required": ["id", "name"],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
}
}
"id": {"type": "integer", "format": "int64"},
"name": {"type": "string"},
"tag": {"type": "string"},
},
}
}
},
}

for endpoint in endpoints:
Expand All @@ -84,10 +70,7 @@ def test_openapi(self):
"description": None,
"produces": [None],
"parameters": [None],
"responses": {
"200": {},
"default": {}
}
"responses": {"200": {}, "default": {}},
}

if url in base_spec["paths"]:
Expand All @@ -103,37 +86,25 @@ def test_asyncapi(self):
events = list()
for name in config.services:
decorators = EnrouteAnalyzer(name, config).get_broker_event()
events += [
{"topic": decorator.topic} for decorator in set(chain(*decorators.values()))
]
events += [{"topic": decorator.topic} for decorator in set(chain(*decorators.values()))]

base_spec = {
"asyncapi": "2.0.0",
"info": {
"title": None,
"version": None
},
"info": {"title": None, "version": None},
"description": None,
"license": "MIT",
"servers": {
"url": f'{config.broker.host}:{config.broker.port}'
},
"channels": {}
"servers": {"url": f"{config.broker.host}:{config.broker.port}"},
"channels": {},
}

for event in events:
topic: str = event["topic"]
event_spec = {
"publish": {
"operationId": None,
"message": None
}
}
event_spec = {"publish": {"operationId": None, "message": None}}

base_spec["channels"][topic] = event_spec

pass


if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()