-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Examples needed #1
Comments
@dantownsend It would be great if you add example of |
@falled10 You're right - there aren't any examples or docs yet when it comes to testing. I've created an issue to add them: In Piccolo's own test suite, I tend to launch pytest using a shell script, which specifies a different piccolo_conf file to use for tests, which points to a test database. Something like this: #!/bin/bash
export PICCOLO_CONF="piccolo_conf_test"
python -m pytest -s $@ Does that help? |
@dantownsend not exactly, it didn't create a new test database |
@falled10 This workaround should work. It assumes you're using Piccolo migrations. Create a file like #!/bin/bash
psql -c "DROP DATABASE IF EXISTS my_test_db;"
psql -c "CREATE DATABASE my_test_db;"
export PICCOLO_CONF="piccolo_conf_test"
piccolo migrations forwards all
python -m pytest tests/ Also have a from piccolo_conf import *
from piccolo.engine.postgres import PostgresEngine
DB = PostgresEngine(
config={
"host": "localhost",
"port": "5432",
"user": "postgres",
"password": "",
"database": "my_test_db",
}
) If you're not using Piccolo migrations, you can alternatively call It's my intention to document this properly, and to potentially create a custom test runner, to remove the need for the shell script. |
Hi Daniel |
@sinisaos Amazing, thanks. I had a look yesterday, and am really impressed. I'll play around with it some more today, and will add it to the docs. |
@dantownsend Thank you very much. I'm glad you like it. If you want I can make PR to piccolo_api docs and add something like this to task example in FastAPIWrapper section
What do you think? |
@sinisaos That's a good idea. I haven't actually used the OAuth2 features of FastAPI before - I'm learning about them from your project. I like how it integrates with the OpenAPI docs. How about creating a sub page in the Piccolo API docs which has some advanced recipes for using FastAPI with Piccolo? There could be a page about authentication, including your example code. |
@dantownsend Great. That's better idea and you can use any code sample you need. I also never used FastAPI before (I always experimenting with Starlette which I like better but OpenAPI integration from FastAPI is great). I just mix example from FastAPI security section with great login() function from Piccolo BaseUser. I must admit that FastAPIWrapper is actually guilty for trying FastAPI for the first time :) |
Let me know a use case that you have for an async ORM, and I'll add an example which uses Piccolo.
Alternatively add your own example, or let me know about a project which is using it, and I'll list it here.
The text was updated successfully, but these errors were encountered: