-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
274 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,45 @@ | ||
from lato import Application, ApplicationModule, Command, TransactionContext | ||
from lato.compositon import compose | ||
from lato import Application, ApplicationModule, Command | ||
|
||
|
||
class GetAllItemDetails(Command): | ||
pass | ||
|
||
|
||
pricing_module = ApplicationModule("pricing") | ||
|
||
|
||
@pricing_module.handler(GetAllItemDetails) | ||
def get_item_price(command: GetAllItemDetails): | ||
prices = {'pencil': 1, 'pen': 2} | ||
prices = {"pencil": 1, "pen": 2} | ||
return prices | ||
|
||
|
||
warehouse_module = ApplicationModule("warehouse") | ||
|
||
|
||
@warehouse_module.handler(GetAllItemDetails) | ||
def get_item_stock(command: GetAllItemDetails): | ||
stocks = {'pencil': 100, 'pen': 80} | ||
stocks = {"pencil": 100, "pen": 80} | ||
return stocks | ||
|
||
|
||
app = Application() | ||
app.include_submodule(pricing_module) | ||
app.include_submodule(warehouse_module) | ||
|
||
|
||
@app.compose(GetAllItemDetails) | ||
def compose_item_details(pricing, warehouse): | ||
assert pricing == {'pencil': 1, 'pen': 2} | ||
assert warehouse == {'pencil': 100, 'pen': 80} | ||
assert pricing == {"pencil": 1, "pen": 2} | ||
assert warehouse == {"pencil": 100, "pen": 80} | ||
|
||
details = [dict(item_id=x, price=pricing[x], stock=warehouse[x]) for x in pricing.keys()] | ||
details = [ | ||
dict(item_id=x, price=pricing[x], stock=warehouse[x]) for x in pricing.keys() | ||
] | ||
return details | ||
|
||
|
||
assert app.execute(GetAllItemDetails()) == [ | ||
{'item_id': 'pencil', 'price': 1, 'stock': 100}, | ||
{'item_id': 'pen', 'price': 2, 'stock': 80} | ||
{"item_id": "pencil", "price": 1, "stock": 100}, | ||
{"item_id": "pen", "price": 2, "stock": 80}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "lato" | ||
version = "0.11.1" | ||
version = "0.12.0" | ||
description = "Lato is a Python microframework designed for building modular monoliths and loosely coupled applications." | ||
authors = ["Przemysław Górecki <[email protected]>"] | ||
readme = "README.md" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.