26 lines
883 B
Python
26 lines
883 B
Python
from recipe_graph import scrape
|
|
from bs4 import BeautifulSoup
|
|
|
|
import pytest
|
|
|
|
|
|
def test_load_page():
|
|
page = scrape.load_page("https://hs.andreistoica.ca:4943")
|
|
assert type(page) == BeautifulSoup
|
|
|
|
page = scrape.load_page("https://hs.andreistoica.ca:4943/some-nonesense")
|
|
assert page == None
|
|
|
|
|
|
def test_ingredient_regex():
|
|
regex = scrape.ingredient_regex(["cup"], ["crushed"])
|
|
assert (
|
|
regex.pattern
|
|
== "((?:[\\d\\./\\u00BC-\\u00BE\\u2150-\\u215E]*\\s?(?:\\(.+\\))?)*)((?:(?:[cC]up)e?s?)?)((?:(?:(?:[cC]rushed)(?:ly)?)| )*)([a-zA-Z '\\-]+),?(.*)"
|
|
)
|
|
regex = scrape.ingredient_regex(["cup", "ounce"], ["crushed", "ground"])
|
|
assert (
|
|
regex.pattern
|
|
== "((?:[\\d\\./\\u00BC-\\u00BE\\u2150-\\u215E]*\\s?(?:\\(.+\\))?)*)((?:(?:[cC]up|[oO]unce)e?s?)?)((?:(?:(?:[cC]rushed|[gG]round)(?:ly)?)| )*)([a-zA-Z '\\-]+),?(.*)"
|
|
)
|