-
-
Notifications
You must be signed in to change notification settings - Fork 172
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
feature: MongoDB support via beanie #187
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi and thanks for your AWESOME WORK! But I have some questions and suggestions regarding the PR.
Few things to add:
- Services for Github actions and Gitlab-Ci. It's used by generate CI option.
- Fix dummy for GraphQL in web/gql folder. Since it's the same as for REST right now.
- Can you please add test in
fastapi_template/tests/test_generator.py
? Because we need to be sure that after the project generation, all generated tests are passing.
Thank you very much. I really appreciate the work you did.
fastapi_template/template/{{cookiecutter.project_name}}/deploy/docker-compose.yml
Outdated
Show resolved
Hide resolved
fastapi_template/template/{{cookiecutter.project_name}}/deploy/docker-compose.yml
Show resolved
Hide resolved
fastapi_template/template/{{cookiecutter.project_name}}/conditional_files.json
Outdated
Show resolved
Hide resolved
...emplate/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/web/lifetime.py
Outdated
Show resolved
Hide resolved
.../template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/web/api/dummy/views.py
Outdated
Show resolved
Hide resolved
Actually, you can easily test the project generations by creating one command and running it everytime you make changes. For example. fastapi_template --name myproject --db mongo --api-type rest --orm beanie --dummy --routers --quite --force This command will be overriding all files within myproject folder. It helps me fixing all flake errors. |
Also, you should not start DB separately from the project. The main point is that the docker compose up --build |
525f418
to
d600c16
Compare
Signed-off-by: Tsung-Ju Lii <[email protected]>
d600c16
to
d7c3207
Compare
fastapi_template/template/{{cookiecutter.project_name}}/deploy/docker-compose.yml
Outdated
Show resolved
Hide resolved
Signed-off-by: Tsung-Ju Lii <[email protected]>
aeb2d17
to
893dde3
Compare
Hi @s3rius , I think I addressed all the things you suggested:
I also made sure all flake8 warnings are gone, mypy does not complain, and that I was able to create & read dummy models with the containers started by docker compose. However I wasn't able to get pytest to run successfully (both in
and running tests in Thanks! |
Hi @s3rius, I modified the PR per your suggestions, please check out the changes and see if they make sense when you have time, thanks a bunch! |
Hi @s3rius , sorry for the lack of response. I've addressed all your suggestions in the latest commit, please take a look when you have time.
async def test_creation(
fastapi_app: FastAPI,
client: AsyncClient,
) -> None:
"""Tests dummy instance creation."""
url = fastapi_app.url_path_for("create_dummy_model")
test_name = uuid.uuid4().hex
response = await client.put(
url,
json={
"name": test_name,
},
) # Inserts a Dummy into DB
# ... snipped ...
@pytest.mark.anyio
async def test_getting(
fastapi_app: FastAPI,
client: AsyncClient,
) -> None:
"""Tests dummy instance retrieval."""
dao = DummyDAO()
test_name = uuid.uuid4().hex
await dao.create_dummy_model(name=test_name) # XXX Inserts another Dummy into DB??
url = fastapi_app.url_path_for("get_dummy_models")
response = await client.get(url)
dummies = response.json()
assert response.status_code == status.HTTP_200_OK
assert len(dummies) == 1 # XXX Should be 2?
I decided to remove the inserted object in Thanks! |
Hi @s3rius , I believe this is complete now. Thanks! |
@s3rius ping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry. I couldn't find time to review. It takes a lot of time to review every request to this project.
But thank you very much for implementing it. I know how much effort it takes to implement something like this.
fastapi_template/template/{{cookiecutter.project_name}}/conditional_files.json
Show resolved
Hide resolved
fastapi_template/template/{{cookiecutter.project_name}}/deploy/docker-compose.yml
Show resolved
Hide resolved
...template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/web/api/dummy/schema.py
Show resolved
Hide resolved
...emplate/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/web/lifetime.py
Outdated
Show resolved
Hide resolved
…iecutter.project_name}}/web/lifetime.py Co-authored-by: Pavel Kirilin <[email protected]>
Okay. I don't know what is happening, but now mypy seems to complain about some types. Can you fix it? Just add an |
Sorry I missed a |
I don't get it... |
@usefulalgorithm, that's fine. Happens sometimes. Will rerun tests. |
I will try to fix the problem on develop branch. Thanks for your outstanding contribution. |
Adds support for MongoDB and Beanie. Probably fixes #119 ?
I did a simple crud app with virtually the same setup, seems to be working fine.
Demos
db
service is placed indocker-compose.dev.yaml
instead ofdocker-compose.yml
Settings
has a separate section for mongodb settingsTodos / caveats / things to note:
admin
database