1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-07-24 15:49:42 +02:00

chore: file generation cleanup (#1736)

This PR does too many things :( 

1. Major refactoring of the dev/scripts and dev/code-generation folders. 

Primarily this was removing duplicate code and cleaning up some poorly written code snippets as well as making them more idempotent so then can be re-run over and over again but still maintain the same results. This is working on my machine, but I've been having problems in CI and comparing diffs so running generators in CI will have to wait. 

2. Re-Implement using the generated api routes for testing

This was a _huge_ refactor that touched damn near every test file but now we have auto-generated typed routes with inline hints and it's used for nearly every test excluding a few that use classes for better parameterization. This should greatly reduce errors when writing new tests. 

3. Minor Perf improvements for the All Recipes endpoint

  A. Removed redundant loops
  B. Uses orjson to do the encoding directly and returns a byte response instead of relying on the default 
       jsonable_encoder.

4. Fix some TS type errors that cropped up for seemingly no reason half way through the PR.

See this issue https://github.com/phillipdupuis/pydantic-to-typescript/issues/28

Basically, the generated TS type is not-correct since Pydantic will automatically fill in null fields. The resulting TS type is generated with a ? to indicate it can be null even though we _know_ that i can't be.
This commit is contained in:
Hayden 2022-10-18 14:49:41 -08:00 committed by GitHub
parent a8f0fb14a7
commit 9ecef4c25f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
107 changed files with 2520 additions and 1948 deletions

View file

@ -4,14 +4,14 @@ from mealie.schema.recipe.recipe import RecipeTool
from mealie.schema.recipe.recipe_tool import RecipeToolSave
from tests import utils
from tests.multitenant_tests.case_abc import ABCMultiTenantTestCase
from tests.utils import routes
from tests.utils import api_routes
class ToolsTestCase(ABCMultiTenantTestCase):
items: list[RecipeTool]
def seed_action(self, group_id: str) -> set[int]:
tool_ids: set[int] = set()
def seed_action(self, group_id: str) -> set[str]:
tool_ids: set[str] = set()
for _ in range(10):
tool = self.database.tools.create(
RecipeToolSave(
@ -25,9 +25,9 @@ class ToolsTestCase(ABCMultiTenantTestCase):
return tool_ids
def seed_multi(self, group1_id: str, group2_id: str) -> tuple[set[int], set[int]]:
g1_item_ids = set()
g2_item_ids = set()
def seed_multi(self, group1_id: str, group2_id: str) -> tuple[set[str], set[str]]:
g1_item_ids: set[str] = set()
g2_item_ids: set[str] = set()
for group_id, item_ids in [(group1_id, g1_item_ids), (group2_id, g2_item_ids)]:
for _ in range(10):
@ -44,7 +44,7 @@ class ToolsTestCase(ABCMultiTenantTestCase):
return g1_item_ids, g2_item_ids
def get_all(self, token: str) -> Response:
return self.client.get(routes.organizers.Tools.base, headers=token)
return self.client.get(api_routes.organizers_tools, headers=token)
def cleanup(self) -> None:
for item in self.items: