diff --git a/cookbook/tests/other/test_data/marmiton.html b/cookbook/tests/other/test_data/marmiton.html new file mode 100644 index 00000000..fe45c226 --- /dev/null +++ b/cookbook/tests/other/test_data/marmiton.html @@ -0,0 +1,2267 @@ + + + + + + + + + + + + + + + + + + + + + + + + + Fricassée d'agneau à l'oseille : Recette de Fricassée d'agneau à l'oseille - Marmiton + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ +
+
+
+

+ Accueil > Recettes > Fricassée d'agneau à l'oseille

+ + +
+ + +

Fricassée d'agneau à l'oseille

+ + +
+
+
5/5 +
+ + + + + + 3 commentaires + +
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+
+ +
+
+
+ +
+
+ + + + Marmiton.org + + +
+
+ + +
+ + +
+ 1/1 +
+
+ +
+ +
+
+ + 55 min +
+ +
+ + très facile +
+ +
+ + moyen +
+
+
+ +
+ + +
+ + + +
+ +
+
+
+
+ + + + +
+
+

Ingrédients

+

Ustensiles

+
+ +
+ + + + + + + + +
+
+
+ + +
+
+ + + + +
+
+ +
+ +
+ +
    +
  • +
    + + + + + + +
    + + + +
    + +
    +
    + + + +
    + + +
    +
    +
  • +
  • +
    + + + + + + +
    + + + +
    + +
    +
    + 20 + + cl +
    + + +
    +
    +
  • +
  • +
    + + + + + + +
    + + + +
    + +
    +
    + 1 + + cuillère à soupe +
    + + +
    +
    +
  • +
  • +
    + + + + + + +
    + + + +
    + +
    +
    + 1 + + kg +
    + +
    + + épaule + + agneau + + + 1 +
    +
    +
    +
  • +
  • +
    + + + + + + +
    + + + +
    + +
    +
    + 200 + + g +
    + +
    + + oseille + + + + + 200 +
    +
    +
    +
  • +
  • +
    + + + + + + +
    + + + +
    + +
    +
    + 80 + + g +
    + +
    + + beurre + + + + + 80 +
    +
    +
    +
  • +
  • +
    + + + + + + +
    + + + +
    + +
    +
    + 2 + + +
    + +
    + + oignon + + moyens + + + 2 +
    +
    +
    +
  • +
  • +
    + + + + + + +
    + + + +
    + +
    +
    + 1 + + +
    + +
    + + jaune d'oeuf + + + + + 1 +
    +
    +
    +
  • +
  • +
    + + + + + + +
    + + + +
    + +
    +
    + + + +
    + +
    + + huile + + + + + huile +
    +
    +
    +
  • +
  • +
    + + + + + + +
    + + + +
    + +
    +
    + + + +
    + +
    + + poivre + + + + + poivre +
    +
    +
    +
  • +
+
+ + + + +
+
+
+ +
+ + + + +
+
+

Préparation

+
+ +
+
+ Temps Total :  +
55 min
+
+
+
+ Préparation : +
10 min
+
+
+ Repos : +
-
+
+
+ Cuisson : +
45 min
+
+
+
+ + +
+
+
+ Étape 1 +
+ +

Dans une poêle, faire sauter l'agneau coupé en gros dés avec l'huile et le beurre. Le laisser colorer et assaisonner.

+
+
+
+ Étape 2 +
+ +

Réserver la viande au chaud et la remplacer par les oignons émincés et la farine. Les faire revenir jusqu'à coloration et mouiller avec le bouillon. Assaisonner et ajouter l'oseille.

+
+
+
+ Étape 3 +
+ +

Replacer les dés d'agneau et laisser cuire à feu doux, à couvert pendant 30 min.

+
+
+
+ Étape 4 +
+ +

Au moment de servir, mettre les morceaux de viande dans le plat de service.

+
+
+
+ Étape 5 +
+ +

Incorporer très vite le jaune d'oeuf et napper la viande de sauce.

+
+
+
+ +
+
+ + +
+ + + + +
+ +
+
+
+ F + Fée du fourneau +
+ +
+ + +
+
+ +
+
+ +
+
+

Vous allez adorer

+ + + +
+
+ +
+
+ + +
+
+
+
+ +
+
+ C’est terminé ! Qu’en avez-vous pensé ?
+
+
+
+ +
+ + Ajouter ma photo +
+ +
+
+ +

+ +

+ + + + + Le délai de validation est d'environ 5 jours ouvrés.
+
+
+
+
+
+
+
+
+
+ + +
+ +
+ +
+

Soif de recettes ?

+

On se donne rendez-vous dans votre boîte mail !

+
+
+ + Découvrir nos newsletters +
+ +
+ + +

User already comment this recipe

+

User already comment this recipe

+

User can't comment his own recipe

+ +
+
+
+

Commentaires (3)

+
+
+
+
+ + +
+
+
+ +

+ Voir Plus +

+ +
+ + +
+
+
+ + + + + +
+
+
+
+
+
Marmiton Mag
+
Et si vous vous abonniez ?
+
+
C'est la meilleure manière de ne rater aucun numéro, de faire des économies et de se régaler tous les deux mois :) En plus vous aurez accès à la version numérique pour lire vraiment partout.
+ VOIR LES SUPER OFFRES +
+
+ Boutique Boutique
+
+
+
+ + +
+ +
+
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cookbook/tests/other/test_url_import.py b/cookbook/tests/other/test_url_import.py index 9f7ba619..76d3d69e 100644 --- a/cookbook/tests/other/test_url_import.py +++ b/cookbook/tests/other/test_url_import.py @@ -1,50 +1,81 @@ import json import pytest + from django.urls import reverse -from ._recipes import (AMERICAS_TEST_KITCHEN) +from ._recipes import (ALLRECIPES, AMERICAS_TEST_KITCHEN, CHEF_KOCH, COOKPAD, + COOKS_COUNTRY, DELISH, FOOD_NETWORK, GIALLOZAFFERANO, JOURNAL_DES_FEMMES, + MADAME_DESSERT, MARMITON, TASTE_OF_HOME, TUDOGOSTOSO) - -IMPORT_SOURCE_URL = 'data_import_source' +IMPORT_SOURCE_URL = 'api_recipe_from_source' +DATA_DIR = "cookbook/tests/other/test_data/" # These were chosen arbitrarily from: # Top 10 recipe websites listed here https://www.similarweb.com/top-websites/category/food-and-drink/cooking-and-recipes/ # plus the test that previously existed -# custom scraper that was created +# plus the custom scraper that was created # TODO thoughtfully add recipes that test specific scenerios - @pytest.mark.parametrize("arg", [ - ['a_u', 403], - ['g1_s1', 404], - ['u1_s1', 200], - ['a1_s1', 404], - ['g1_s2', 404], - ['u1_s2', 404], - ['a1_s2', 404], + ['a_u', 302], + ['g1_s1', 302], + ['u1_s1', 400], + ['a1_s1', 400], ]) def test_import_permission(arg, request): c = request.getfixturevalue(arg[0]) assert c.get(reverse(IMPORT_SOURCE_URL)).status_code == arg[1] -# TODO this test is really bad, need to find a better solution, also pytest does not like those paths -# def test_ld_json(): -# with scopes_disabled(): -# test_list = [ -# {'file': 'resources/websites/ld_json_1.html', 'result_length': 3237}, -# {'file': 'resources/websites/ld_json_2.html', 'result_length': 1525}, -# {'file': 'resources/websites/ld_json_3.html', 'result_length': 1644}, -# {'file': 'resources/websites/ld_json_4.html', 'result_length': 1744}, -# {'file': 'resources/websites/ld_json_itemList.html', 'result_length': 3222}, -# {'file': 'resources/websites/ld_json_multiple.html', 'result_length': 1621}, -# {'file': 'resources/websites/micro_data_1.html', 'result_length': 1094}, -# {'file': 'resources/websites/micro_data_2.html', 'result_length': 1453}, -# {'file': 'resources/websites/micro_data_3.html', 'result_length': 1163}, -# {'file': 'resources/websites/micro_data_4.html', 'result_length': 4411}, -# ] -# -# for test in test_list: -# with open(test['file'], 'rb') as file: -# print(f'Testing {test["file"]} expecting length {test["result_length"]}') -# parsed_content = json.loads(get_from_html(file.read(), 'test_url', None).content) -# assert len(str(parsed_content)) == test['result_length'] -# file.close() + + +@pytest.mark.parametrize("arg", [ + ALLRECIPES, + AMERICAS_TEST_KITCHEN, + CHEF_KOCH, + COOKPAD, + COOKS_COUNTRY, + DELISH, + FOOD_NETWORK, + GIALLOZAFFERANO, + JOURNAL_DES_FEMMES, + MADAME_DESSERT, + MARMITON, + TASTE_OF_HOME, + TUDOGOSTOSO +]) +def test_recipe_import(arg, u1_s1): + for f in arg['file']: + with open(DATA_DIR + f, 'r', encoding='UTF-8') as d: + response = u1_s1.post( + reverse(IMPORT_SOURCE_URL), + { + 'data': d.read(), + 'url': arg['url'], + 'mode': 'source' + }, + files={'foo': 'bar'} + ) + recipe = json.loads(response.content)['recipe_json'] + for key in list(set(arg) - set(['file', 'url'])): + if type(arg[key]) == list: + assert len(recipe[key]) == len(arg[key]) + if key == 'keywords': + valid_keywords = [i['text'] for i in arg[key]] + for k in recipe[key]: + assert k['text'] in valid_keywords + elif key == 'recipeIngredient': + valid_ing = ["{:g}{}{}{}{}".format( + i['amount'], + i['unit']['text'], + i['ingredient']['text'], + i['note'], + i['original']) + for i in arg[key]] + for i in recipe[key]: + assert "{:g}{}{}{}{}".format( + i['amount'], + i['unit']['text'], + i['ingredient']['text'], + i['note'], + i['original']) in valid_ing + else: + assert recipe[key] == arg[key]