Exemplo n.º 1
0
 def _fetch_data_from_request(request):
     soup = BeautifulSoup(request.text, "html.parser")
     links = soup.findAll("div", {"class": "yuRUbf"})
     fetched_data = []
     for link in links:
         item_text = link.find("h3").text
         item_link = link.find("a").attrs["href"]
         sr = SearchResult.parse(item_text, item_link)
         fetched_data.append(sr)
     return fetched_data
Exemplo n.º 2
0
 def _filter_movie_service_result(search_result: SearchResult):
     link = str(search_result.link())
     return link.startswith(r"https://www.filmweb.pl/film/")
Exemplo n.º 3
0
def sample_select_menu():
    """Returns sample SelectMenu"""
    movies_names = ['Titanic', 'Green Book', "Green mile"]
    menu_items = map(lambda x: SearchResult.parse(x, x), movies_names)
    return SelectMenu(menu_items)
Exemplo n.º 4
0
def test_invalid_arguments_shoud_raises_an_exception():
    with pytest.raises(TypeError) as e:
        SearchResult.parse([], '')

    with pytest.raises(TypeError) as e:
        SearchResult.parse('', [])
Exemplo n.º 5
0
def empty_search_result():
    """Returns an empty SearchResult"""
    return SearchResult.parse('', '')
Exemplo n.º 6
0
def test_parsing_some_data_to_search_result():
    search_result = SearchResult.parse(example_film_title, example_film_link)
    assert search_result is not None
    assert search_result.link() == example_film_link
    assert search_result.title() == example_film_title
Exemplo n.º 7
0
def test_parse_fetched_film_title():
    search_result = SearchResult.parse('Titanic - Filmweb', '')
    assert search_result.title() == 'Titanic'
Exemplo n.º 8
0
def example_search_result():
    """Returns an SearchResult with sample data"""
    return SearchResult.parse(example_film_title, example_film_link)
def sample_search_result():
    return SearchResult.parse('Titanic', 'https://www.filmweb.pl/film/titanic...')
def test_should_filter_movie_reject_result():
    dummy_search_result = SearchResult.parse('Titanic', 'https://dummy_page.com/films')
    assert MovieSearchEngine._filter_movie_service_result(dummy_search_result) == False