Skip to content
Closed
Show file tree
Hide file tree
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
33 changes: 33 additions & 0 deletions .github/workflows/minos-rest-aiohttp-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: "Publish: minos-rest-aiohttp"

on:
push:
branches:
- '*.*.x'
paths:
- 'packages/plugins/minos-rest-aiohttp/**'

jobs:
deploy:
runs-on: ubuntu-latest
container: python:3.9-buster
defaults:
run:
working-directory: packages/plugins/minos-rest-aiohttp

steps:

- name: Check out repository code
uses: actions/checkout@v2

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install dependencies
run: make install

- name: Publish package
run: make release
env:
POETRY_HTTP_BASIC_PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
POETRY_HTTP_BASIC_PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
66 changes: 66 additions & 0 deletions .github/workflows/minos-rest-aiohttp-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: "Test: minos-rest-aiohttp"

on:
push:
branches:
- main
- '*.*.x'
pull_request:
paths:
- 'packages/plugins/minos-rest-aiohttp/**'
- 'packages/core/minos-microservice-networks/**'
- 'packages/core/minos-microservice-common/**'

jobs:
build:
runs-on: ubuntu-latest
container: python:3.9-buster
defaults:
run:
working-directory: packages/plugins/minos-rest-aiohttp

services:
postgres:
image: postgres
env:
POSTGRES_USER: minos
POSTGRES_PASSWORD: min0s
POSTGRES_DB: order_db
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

env:
MINOS_BROKER_QUEUE_HOST: postgres
MINOS_BROKER_HOST: kafka
MINOS_REPOSITORY_HOST: postgres
MINOS_SNAPSHOT_HOST: postgres

steps:
- name: Check out repository code
uses: actions/checkout@v2

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install dependencies
run: make install

- name: Lint package
run: make lint

- name: Test package with coverage
run: make coverage

- name: Publish coverage
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./packages/plugins/minos-rest-aiohttp/coverage.xml
fail_ci_if_error: true

- name: Generate documentation
run: make docs

- name: Generate build
run: make dist
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,10 @@ repos:
name: Check minos-broker-kafka
files: ^packages/plugins/minos-broker-kafka/
language: system

- id: minos-rest-aiohttp-check
pass_filenames: false
entry: make --directory=packages/plugins/minos-rest-aiohttp check
name: Check minos-rest-aiohttp
files: ^packages/plugins/minos-rest-aiohttp/
language: system
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,6 @@
ResponseException,
WrappedRequest,
)
from .rest import (
RestHandler,
RestRequest,
RestResponse,
RestResponseException,
RestService,
)
from .scheduling import (
PeriodicTask,
PeriodicTaskScheduler,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
ABC,
)
from typing import (
Any,
Optional,
)
from uuid import (
UUID,
)

from minos.networks import (
NotHasContentException,
Request,
Response,
)
Expand All @@ -24,6 +26,35 @@ def test_abstract(self):
# noinspection PyUnresolvedReferences
self.assertEqual({"__eq__", "__repr__", "has_content", "has_params", "user"}, Request.__abstractmethods__)

async def test_not_has_content_raises(self):
class _Request(Request):
@property
def user(self) -> Optional[UUID]:
"""For testing purposes."""
return None

@property
def has_content(self) -> bool:
"""For testing purposes."""
return False

@property
def has_params(self) -> bool:
"""For testing purposes."""
return True

async def _content(self, **kwargs) -> Any:
return True

def __eq__(self, other: Request) -> bool:
return True

def __repr__(self) -> str:
return str()

with self.assertRaises(NotHasContentException):
await _Request().content()

async def test_content_raises(self):
class _Request(Request):
@property
Expand Down
15 changes: 15 additions & 0 deletions packages/plugins/minos-rest-aiohttp/AUTHORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Credits

## Development Lead

* Andrea Mucci <andrea@clariteia.com>

## Core Devs

* Sergio Garcia Prado <sergio.garcia@clariteia.com>
* Vladyslav Fenchak <vladyslav.fenchak@clariteia.com>
* Alberto Amigo Alonso <alberto.amigo@clariteia.com>

## Contributors

None yet. Why not be the first?
5 changes: 5 additions & 0 deletions packages/plugins/minos-rest-aiohttp/HISTORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# History

## 0.0.1 (2022-02-17)

* First release on PyPI.
21 changes: 21 additions & 0 deletions packages/plugins/minos-rest-aiohttp/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Clariteia

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
42 changes: 42 additions & 0 deletions packages/plugins/minos-rest-aiohttp/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.PHONY: docs

lint:
poetry run flake8

test:
poetry run pytest

coverage:
poetry run coverage run -m pytest
poetry run coverage report -m
poetry run coverage xml

reformat:
poetry run black --line-length 120 minos tests
poetry run isort minos tests

docs:
rm -rf docs/api
poetry run $(MAKE) --directory=docs html

release:
$(MAKE) dist
poetry publish

dist:
poetry build
ls -l dist

install:
poetry install

update:
poetry update

check:
$(MAKE) install
$(MAKE) reformat
$(MAKE) lint
$(MAKE) test
$(MAKE) docs
$(MAKE) dist
36 changes: 36 additions & 0 deletions packages/plugins/minos-rest-aiohttp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<p align="center">
<a href="http://minos.run" target="_blank"><img src="https://raw.githubusercontent.com/minos-framework/.github/main/images/logo.png" alt="Minos logo"></a>
</p>

## minos-rest-aiohttp

[![PyPI Latest Release](https://img.shields.io/pypi/v/minos-rest-aiohttp.svg)](https://pypi.org/project/minos-rest-aiohttp/)
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/minos-framework/minos-python/pages%20build%20and%20deployment?label=docs)](https://minos-framework.github.io/minos-python)
[![License](https://img.shields.io/github/license/minos-framework/minos-python.svg)](https://github.com/minos-framework/minos-python/blob/main/LICENSE)
[![Coverage](https://codecov.io/github/minos-framework/minos-python/coverage.svg?branch=main)](https://codecov.io/gh/minos-framework/minos-python)
[![Stack Overflow](https://img.shields.io/badge/Stack%20Overflow-Ask%20a%20question-green)](https://stackoverflow.com/questions/tagged/minos)

## Summary

Minos is a framework which helps you create [reactive](https://www.reactivemanifesto.org/) microservices in Python.
Internally, it leverages Event Sourcing, CQRS and a message driven architecture to fulfil the commitments of an
asynchronous environment.

## Documentation

The official API Reference is publicly available at the [GitHub Pages](https://minos-framework.github.io/minos-python).

## Source Code

The source code of this project is hosted at the [GitHub Repository](https://github.com/minos-framework/minos-python).

## Getting Help

For usage questions, the best place to go to is [StackOverflow](https://stackoverflow.com/questions/tagged/minos).

## Discussion and Development
Most development discussions take place over the [GitHub Issues](https://github.com/minos-framework/minos-python/issues). In addition, a [Gitter channel](https://gitter.im/minos-framework/community) is available for development-related questions.

## License

This project is distributed under the [MIT](https://raw.githubusercontent.com/minos-framework/minos-python/main/LICENSE) license.
21 changes: 21 additions & 0 deletions packages/plugins/minos-rest-aiohttp/RUNTHETESTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Run the tests
==============

In order to run the tests, please make sure you have the `Docker Engine <https://docs.docker.com/engine/install/>`_
and `Docker Compose <https://docs.docker.com/compose/install/>`_ installed.

Move into tests/ directory

`cd tests/`

Run service dependencies:

`docker-compose up -d`

Install library dependencies:

`make install`

Run tests:

`make test`
11 changes: 11 additions & 0 deletions packages/plugins/minos-rest-aiohttp/SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Set up a development environment
=================================

Since we use `poetry` as the default package manager, it must be installed. Please refer to
`https://python-poetry.org/docs/#installation`.

Run `poetry install` to get the dependencies.

Run `pre-commit install` to set the git checks before commiting.

Make yourself sure you are able to run the tests. Refer to the appropriate section in this guide.
20 changes: 20 additions & 0 deletions packages/plugins/minos-rest-aiohttp/docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = python -msphinx
SPHINXPROJ = minos-rest-aiohttp
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
1 change: 1 addition & 0 deletions packages/plugins/minos-rest-aiohttp/docs/authors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.. mdinclude:: ../AUTHORS.md
Loading