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

Refactor/conver to controllers (#923)

* add dependency injection for get_repositories

* convert events api to controller

* update generic typing

* add abstract controllers

* update test naming

* migrate admin services to controllers

* add additional admin route tests

* remove print

* add public shared dependencies

* add types

* fix typo

* add static variables for recipe json keys

* add coverage gutters config

* update controller routers

* add generic success response

* add category/tag/tool tests

* add token refresh test

* add coverage utilities

* covert comments to controller

* add todo

* add helper properties

* delete old service

* update test notes

* add unit test for pretty_stats

* remove dead code from post_webhooks

* update group routes to use controllers

* add additional group test coverage

* abstract common permission checks

* convert ingredient parser to controller

* update recipe crud to use controller

* remove dead-code

* add class lifespan tracker for debugging

* convert bulk export to controller

* migrate tools router to controller

* update recipe share to controller

* move customer router to _base

* ignore prints in flake8

* convert units and foods to new controllers

* migrate user routes to controllers

* centralize error handling

* fix invalid ref

* reorder fields

* update routers to share common handling

* update tests

* remove prints

* fix cookbooks delete

* fix cookbook get

* add controller for mealplanner

* cover report routes to controller

* remove __future__ imports

* remove dead code

* remove all base_http children and remove dead code
This commit is contained in:
Hayden 2022-01-13 13:06:52 -09:00 committed by GitHub
parent 5823a32daf
commit c4540f1395
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
164 changed files with 3111 additions and 3213 deletions

View file

@ -0,0 +1,12 @@
from mealie.core import exceptions
from mealie.lang import get_locale_provider
def test_mealie_registered_exceptions() -> None:
provider = get_locale_provider()
lookup = exceptions.mealie_registered_exceptions(provider)
assert "permission" in lookup[exceptions.PermissionDenied]
assert "The requested resource was not found" in lookup[exceptions.NoEntryFound]
assert "integrity" in lookup[exceptions.IntegrityError]

View file

@ -1,3 +1,4 @@
import shutil
from dataclasses import dataclass
from fractions import Fraction
@ -17,7 +18,6 @@ class TestIngredient:
def crf_exists() -> bool:
import shutil
return shutil.which("crf_test") is not None

View file

@ -14,7 +14,7 @@ and then use this test case by removing the `@pytest.mark.skip` and than testing
"""
@pytest.mark.skip
@pytest.mark.skipif(True, reason="Long Running API Test - manually run when updating the parser")
@pytest.mark.parametrize("recipe_test_data", test_cases)
def test_recipe_parser(recipe_test_data: RecipeSiteTestCase):
recipe = scraper.create_from_url(recipe_test_data.url)

View file

@ -0,0 +1,22 @@
import pytest
from mealie.utils.fs_stats import pretty_size
@pytest.mark.parametrize(
"size, expected",
[
(0, "0 bytes"),
(1, "1 bytes"),
(1024, "1.0 KB"),
(1024 ** 2, "1.0 MB"),
(1024 ** 2 * 1024, "1.0 GB"),
(1024 ** 2 * 1024 * 1024, "1.0 TB"),
],
)
def test_pretty_size(size: int, expected: str) -> None:
"""
Test pretty size takes in a integer value of a file size and returns the most applicable
file unit and the size.
"""
assert pretty_size(size) == expected