Skip to content

karimelhajoui63/uow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Run the server

cd src
pdm run uvicorn main:app --workers 8

Call the POST method

curl -X POST "http://localhost:8000/items/" -H "accept: application/json" -H "Content-Type: application/json" -d '{"name":"item_post_route"}'

Conclusion

We can see that if we open 2 terminals, and run:

pdm run tests/post.py test_111

then 1 ou 2 sec after:

pdm run tests/post.py test_222

We have this result (which means that the UoW are isolated in each thread)

--- START ---
Just register in UoW: name='item_post_route_test_111'
add 'item_post_route_test_111' to []
heavy work in progress...
--- START ---
Just register in UoW: name='item_post_route_test_222'
add 'item_post_route_test_222' to []
heavy work in progress...
Just register in UoW: name='another_inner_item'
add 'another_inner_item' to ['item_post_route_test_111']
Just register in UoW: name='inner_item'
add 'inner_item' to ['item_post_route_test_111', 'another_inner_item']
--- END ---
--- EXIT ---
FROM UoW:
Model SAVED in DB: name='item_post_route_test_111'
FROM UoW:
Model SAVED in DB: name='another_inner_item'
FROM UoW:
Model SAVED in DB: name='inner_item'
INFO:     127.0.0.1:63077 - "POST /items/ HTTP/1.1" 200 OK
Just register in UoW: name='another_inner_item'
add 'another_inner_item' to ['item_post_route_test_222']
Just register in UoW: name='inner_item'
add 'inner_item' to ['item_post_route_test_222', 'another_inner_item']
--- END ---
--- EXIT ---
FROM UoW:
Model SAVED in DB: name='item_post_route_test_222'
FROM UoW:
Model SAVED in DB: name='another_inner_item'
FROM UoW:
Model SAVED in DB: name='inner_item'
INFO:     127.0.0.1:63094 - "POST /items/ HTTP/1.1" 200 OK

Bonus

We can also uncomment the raise NotImplementedError() in UseCase and see that no save is done if there is an error in the middle on the UoW

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages