Skip to content

Commit

Permalink
Merge pull request #15 from mcqueary/feature/dependency-changes
Browse files Browse the repository at this point in the history
fixing dependencies
  • Loading branch information
mcqueary authored Dec 15, 2023
2 parents 78cabe7 + 43d4898 commit 96c1d06
Show file tree
Hide file tree
Showing 46 changed files with 33,870 additions and 34,011 deletions.
149 changes: 1 addition & 148 deletions poetry.lock

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,19 @@ readme = "README.md"
[tool.poetry.dependencies]
python = ">=3.8.1,<4.0"
beautifulsoup4 = "4.12.2"
lxml = "4.9.3"
tqdm = "4.66.1"
typer = "0.9.0"


[tool.poetry.group.test.dependencies]
coverage = ">=4.1,<6.0.dev0 || >6.1,<6.1.1 || >6.1.1,<7.0"
faker = "^20.0.3"
coveralls = "^3.3.1"
flake8 = "^6.1.0"
pytest = "^7.4.3"
pytest-cov = "^4.1.0"
pytest-helpers-namespace = "^2021.12.29"
coveralls = "^3.3.1"
pytest-integration = "^0.2.3"
vcrpy = "^5.1.0"


[tool.poetry.group.dev.dependencies]
Expand All @@ -84,7 +83,6 @@ pre-commit = "^3.5.0"
mypy = "^1.7.1"
types-beautifulsoup4 = "^4.12.0.7"
types-tqdm = "^4.66.0.5"
vcrpy = "^5.1.0"


[tool.poetry.scripts]
Expand Down
24 changes: 8 additions & 16 deletions src/graver/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from re import Match
from time import sleep
from typing import List, Optional, cast
from urllib.parse import parse_qs, parse_qsl, urlencode, urlparse, urlunparse
from urllib.parse import parse_qsl, urlparse, urlunparse

import requests
from bs4 import BeautifulSoup, Tag
Expand Down Expand Up @@ -99,7 +99,7 @@ def __init__(self, findagrave_url: str, **kwargs) -> None:

if self.get:
response = self.driver.get(findagrave_url, params=self.params)
self.soup = BeautifulSoup(response.content, "lxml")
self.soup = BeautifulSoup(response.content, "html.parser")

if self.scrape:
self.scrape_cemetery_info()
Expand Down Expand Up @@ -377,7 +377,7 @@ def __init__(self, findagrave_url: str, **kwargs) -> None:

if self.get:
response = self.driver.get(self.findagrave_url)
self.soup = BeautifulSoup(response.content, "lxml")
self.soup = BeautifulSoup(response.content, "html.parser")

if not response.ok:
if self.check_removed():
Expand Down Expand Up @@ -612,7 +612,7 @@ def scrape_page(self):
dt_list = vitals.find("dl").find_all("dt")
for dt in dt_list:
text = dt.get_text(strip=True)
if text == "Original Name":
if text.startswith("Original Name"):
oname = dt.find_next("dd")
self.original_name = oname.get_text()
# elif dt.find("span", id="birthLabel") is not None:
Expand Down Expand Up @@ -844,7 +844,7 @@ def search(self):
# Load the first page to learn how many results there may be
log.debug(f"Search params={self.params}")
response = self.driver.get(self.search_url, params=self.params)
soup = BeautifulSoup(response.content, "lxml")
soup = BeautifulSoup(response.content, "html.parser")

# If this query isn't for a specific page, calculate how many
# pages the results will span
Expand All @@ -865,9 +865,9 @@ def search(self):

# scrape additional pages, if there are any left to get
for i in range(2, num_pages + 1):
url = self.get_page_url(self.search_url, page=i)
response = self.driver.get(url)
soup = BeautifulSoup(response.content, "lxml")
self.params["page"] = i
response = self.driver.get(self.search_url, params=self.params)
soup = BeautifulSoup(response.content, "html.parser")

results = self.scrape_results_page(soup, max_results=(count - len(rs)))
rs.extend(results)
Expand Down Expand Up @@ -1008,14 +1008,6 @@ def scrape_results_page(

return results

@staticmethod
def get_page_url(url, page) -> Optional[str]:
parsed = urlparse(url)
qs: dict = parse_qs(parsed.query)
qs["page"] = int(page)
new_url = parsed._replace(query=urlencode(qs)).geturl()
return new_url


class ResultSet(list):
"""A ResultSet is just a list that keeps track of the object
Expand Down
582 changes: 291 additions & 291 deletions tests/fixtures/vcr_cassettes/404-cemetery.yaml

Large diffs are not rendered by default.

584 changes: 292 additions & 292 deletions tests/fixtures/vcr_cassettes/404-memorial.yaml

Large diffs are not rendered by default.

1,926 changes: 963 additions & 963 deletions tests/fixtures/vcr_cassettes/andrew-jackson.yaml

Large diffs are not rendered by default.

3,375 changes: 1,688 additions & 1,687 deletions tests/fixtures/vcr_cassettes/arlington-national-cemetery-search-results.yaml

Large diffs are not rendered by default.

1,226 changes: 614 additions & 612 deletions tests/fixtures/vcr_cassettes/carl-sagan.yaml

Large diffs are not rendered by default.

932 changes: 466 additions & 466 deletions tests/fixtures/vcr_cassettes/cemetery-monticello-graveyard.yaml

Large diffs are not rendered by default.

2,918 changes: 1,459 additions & 1,459 deletions tests/fixtures/vcr_cassettes/crown-hill-memorial-park.yaml

Large diffs are not rendered by default.

1,703 changes: 852 additions & 851 deletions tests/fixtures/vcr_cassettes/dennis-macalistair-ritchie.yaml

Large diffs are not rendered by default.

1,416 changes: 707 additions & 709 deletions tests/fixtures/vcr_cassettes/george-washington.yaml

Large diffs are not rendered by default.

1,417 changes: 709 additions & 708 deletions tests/fixtures/vcr_cassettes/grace-brewster-hopper.yaml

Large diffs are not rendered by default.

952 changes: 476 additions & 476 deletions tests/fixtures/vcr_cassettes/isaac-asimov.yaml

Large diffs are not rendered by default.

1,910 changes: 955 additions & 955 deletions tests/fixtures/vcr_cassettes/jacob-wolf.yaml

Large diffs are not rendered by default.

1,279 changes: 639 additions & 640 deletions tests/fixtures/vcr_cassettes/james-fenimore-cooper-search-results.yaml

Large diffs are not rendered by default.

1,269 changes: 635 additions & 634 deletions tests/fixtures/vcr_cassettes/john-j-pershing-search-results.yaml

Large diffs are not rendered by default.

1,459 changes: 729 additions & 730 deletions tests/fixtures/vcr_cassettes/john-j-pershing.yaml

Large diffs are not rendered by default.

1,819 changes: 909 additions & 910 deletions tests/fixtures/vcr_cassettes/john-quincy-adams.yaml

Large diffs are not rendered by default.

1,352 changes: 677 additions & 675 deletions tests/fixtures/vcr_cassettes/martin-luther-king.yaml

Large diffs are not rendered by default.

1,839 changes: 922 additions & 917 deletions tests/fixtures/vcr_cassettes/rod-serling.yaml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/fixtures/vcr_cassettes/synopsis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ interactions:
z80ONvYPfbCYvcXRtAguHy0UXuUTVARRZc14fhKYD/9z/2S3cG8R3rPrira5svpfWcKSb8oqAAA=
headers:
Age:
- '15289'
- '1078'
Cache-Control:
- public, max-age=21603
Connection:
Expand All @@ -93,9 +93,9 @@ interactions:
Content-Type:
- text/html; charset=UTF-8
Date:
- Thu, 14 Dec 2023 20:03:23 GMT
- Fri, 15 Dec 2023 20:58:23 GMT
Expires:
- Thu, 14 Dec 2023 20:11:15 GMT
- Fri, 15 Dec 2023 22:44:16 GMT
Keep-Alive:
- timeout=2, max=358
Last-Modified:
Expand Down
4,087 changes: 2,042 additions & 2,045 deletions tests/fixtures/vcr_cassettes/test-cli-scrape-file.yaml

Large diffs are not rendered by default.

765 changes: 382 additions & 383 deletions tests/fixtures/vcr_cassettes/test-search-cemetery-monticello-vets.yaml

Large diffs are not rendered by default.

2,879 changes: 1,440 additions & 1,439 deletions tests/fixtures/vcr_cassettes/test-search-monticello-cemetery-famous-vets.yaml

Large diffs are not rendered by default.

1,715 changes: 857 additions & 858 deletions tests/fixtures/vcr_cassettes/test_cemetery_search-cemetery-641519-p3.yaml

Large diffs are not rendered by default.

2,287 changes: 1,143 additions & 1,144 deletions tests/fixtures/vcr_cassettes/test_cemetery_search_all-rachel-levy-gravesite.yaml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

3,050 changes: 1,526 additions & 1,524 deletions tests/fixtures/vcr_cassettes/test_cemetery_search_max_results.yaml

Large diffs are not rendered by default.

2,299 changes: 1,151 additions & 1,148 deletions tests/fixtures/vcr_cassettes/test_cli_search_in_cemetery.yaml

Large diffs are not rendered by default.

1,267 changes: 633 additions & 634 deletions tests/fixtures/vcr_cassettes/test_cli_search_no_cemetery.yaml

Large diffs are not rendered by default.

1,316 changes: 657 additions & 659 deletions tests/fixtures/vcr_cassettes/test_memorial_parser_merged_raises_exception.yaml

Large diffs are not rendered by default.

1,271 changes: 635 additions & 636 deletions tests/fixtures/vcr_cassettes/test_memorial_parser_removed_raises_exception.yaml

Large diffs are not rendered by default.

1,204 changes: 602 additions & 602 deletions tests/fixtures/vcr_cassettes/test_search_empty.yaml

Large diffs are not rendered by default.

1,269 changes: 634 additions & 635 deletions tests/fixtures/vcr_cassettes/test_search_famous_people-andrew-jackson.yaml

Large diffs are not rendered by default.

1,267 changes: 634 additions & 633 deletions tests/fixtures/vcr_cassettes/test_search_famous_people-carl-sagan.yaml

Large diffs are not rendered by default.

1,279 changes: 640 additions & 639 deletions tests/fixtures/vcr_cassettes/test_search_famous_people-george-washington.yaml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1,269 changes: 634 additions & 635 deletions tests/fixtures/vcr_cassettes/test_search_famous_people-isaac-asimov.yaml

Large diffs are not rendered by default.

1,273 changes: 638 additions & 635 deletions tests/fixtures/vcr_cassettes/test_search_famous_people-john-j-pershing.yaml

Large diffs are not rendered by default.

1,266 changes: 633 additions & 633 deletions tests/fixtures/vcr_cassettes/test_search_famous_people-martin-luther-king.yaml

Large diffs are not rendered by default.

1,269 changes: 635 additions & 634 deletions tests/fixtures/vcr_cassettes/test_search_famous_people-rod-serling.yaml

Large diffs are not rendered by default.

1,281 changes: 641 additions & 640 deletions tests/fixtures/vcr_cassettes/test_search_famous_people-thomas-jefferson.yaml

Large diffs are not rendered by default.

1,011 changes: 505 additions & 506 deletions tests/fixtures/vcr_cassettes/thomas-jefferson.yaml

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,16 @@ def test_search(person: dict, cassette):
assert result.nickname == person["nickname"]


@pytest.mark.parametrize(
"args, expected", [({"lastname": "Jackson", "max_results": 37}, 37)]
)
def test_search_max_results(args, expected):
logging.getLogger().setLevel(logging.DEBUG)
rs = Memorial.search(**args)
assert 0 < len(rs) <= expected
pass


@pytest.mark.parametrize("name", famous_memorials)
def test_search_famous_people(name: str):
person = pytest.helpers.load_memorial_from_json(name)
Expand Down

0 comments on commit 96c1d06

Please sign in to comment.