mealie/tests/utils/assertion_helpers.py
Hayden 92cf97e401
Feature/shopping lists second try (#927)
* generate types

* use generated types

* ui updates

* init button link for common styles

* add links

* setup label views

* add delete confirmation

* reset when not saved

* link label to foods and auto set when adding to shopping list

* generate types

* use inheritence to manage exception handling

* fix schema generation and add test for open_api generation

* add header to api docs

* move list consilidation to service

* split list and list items controller

* shopping list/list item tests - PARTIAL

* enable recipe add/remove in shopping lists

* generate types

* linting

* init global utility components

* update types and add list item api

* fix import cycle and database error

* add container and border classes

* new recipe list component

* fix tests

* breakout item editor

* refactor item editor

* update bulk actions

* update input / color contrast

* type generation

* refactor controller dependencies

* include food/unit editor

* remove console.logs

* fix and update type generation

* fix incorrect type for column

* fix postgres error

* fix delete by variable

* auto remove refs

* fix typo
2022-01-16 15:24:24 -09:00

25 lines
967 B
Python

from requests import Response
def assert_ignore_keys(dict1: dict, dict2: dict, ignore_keys: list = None) -> None:
"""
Itterates through a list of keys and checks if they are in the the provided ignore_keys list,
if they are not in the ignore_keys list, it checks the value of the key in the provided against
the value provided in dict2. If the value of the key in dict1 is not equal to the value of the
key in dict2, The assertion fails. Useful for testing id / group_id agnostic data
Note: ignore_keys defaults to ['id', 'group_id', 'groupId']
"""
if ignore_keys is None:
ignore_keys = ["id", "group_id", "groupId"]
for key, value in dict1.items():
if key in ignore_keys:
continue
else:
assert value == dict2[key]
def assert_derserialize(response: Response, expected_status_code=200) -> dict:
assert response.status_code == expected_status_code
return response.json()