Skip to content

Commit

Permalink
fix formatting for some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rhetr committed Jun 16, 2023
1 parent a88c60b commit d7eeb7a
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 25 deletions.
3 changes: 2 additions & 1 deletion tests/test_chi_housing_authority.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
MINUTES_URL = "http://www.thecha.org/doing-business/contracting-opportunities/view-all/Board%20Meeting" # noqa

upcoming_response = file_response(
join(dirname(__file__), "files", "chi_housing_authority.html"), url=UPCOMING_URL,
join(dirname(__file__), "files", "chi_housing_authority.html"),
url=UPCOMING_URL,
)
notice_response = file_response(
join(dirname(__file__), "files", "chi_housing_authority_notice.html"),
Expand Down
3 changes: 2 additions & 1 deletion tests/test_chi_human_relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@

spider._parse_schedule_pdf(test_pdf_response)
parsed_items = sorted(
[item for item in spider._parse_documents(test_response)], key=itemgetter("start"),
[item for item in spider._parse_documents(test_response)],
key=itemgetter("start"),
)

freezer.stop()
Expand Down
1 change: 0 additions & 1 deletion tests/test_chi_police_retirement.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def test_source():


def test_links():

assert parsed_items[0]["links"] == [
{
"href": "http://www.chipabf.org/ChicagoPolicePension/PDF/Agenda/2019/2019AGENDA01.pdf", # noqa
Expand Down
3 changes: 2 additions & 1 deletion tests/test_chi_ssa_19.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from city_scrapers.spiders.chi_ssa_19 import ChiSsa19Spider

test_response = file_response(
join(dirname(__file__), "files", "chi_ssa_19.html"), url="https://rpba.org/ssa-19/",
join(dirname(__file__), "files", "chi_ssa_19.html"),
url="https://rpba.org/ssa-19/",
)
test_detail_response = file_response(
join(dirname(__file__), "files", "chi_ssa_19_detail.html"),
Expand Down
3 changes: 2 additions & 1 deletion tests/test_chi_ssa_24.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from city_scrapers.spiders.chi_ssa_24 import ChiSsa24Spider

test_response = file_response(
join(dirname(__file__), "files", "chi_ssa_24.html"), url="https://rpba.org/ssa-24/",
join(dirname(__file__), "files", "chi_ssa_24.html"),
url="https://rpba.org/ssa-24/",
)
test_detail_response = file_response(
join(dirname(__file__), "files", "chi_ssa_24_detail.html"),
Expand Down
3 changes: 2 additions & 1 deletion tests/test_chi_ssa_43.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from city_scrapers.spiders.chi_ssa_43 import ChiSsa43Spider

test_response = file_response(
join(dirname(__file__), "files", "chi_ssa_43.html"), url="https://rpba.org/ssa-43/",
join(dirname(__file__), "files", "chi_ssa_43.html"),
url="https://rpba.org/ssa-43/",
)
test_detail_response = file_response(
join(dirname(__file__), "files", "chi_ssa_43_detail.html"),
Expand Down
3 changes: 2 additions & 1 deletion tests/test_chi_ssa_54.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from city_scrapers.spiders.chi_ssa_54 import ChiSsa54Spider

test_response = file_response(
join(dirname(__file__), "files", "chi_ssa_54.html"), url="https://rpba.org/ssa-54/",
join(dirname(__file__), "files", "chi_ssa_54.html"),
url="https://rpba.org/ssa-54/",
)
test_detail_response = file_response(
join(dirname(__file__), "files", "chi_ssa_54_detail.html"),
Expand Down
29 changes: 12 additions & 17 deletions tests/test_il_health_facilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@
url="https://www2.illinois.gov/sites/hfsrb/events/Pages/Board-Meetings.aspx",
)

# The crawler for il_health_facilities grabs information from some pages that are linked to
# from the original page. As such, we need to test the adjacent links as well
# The crawler for il_health_facilities grabs information from some pages that are
# linked to from the original page.
# As such, we need to test the adjacent links as well

adjacent_links = [
"https://www2.illinois.gov/sites/hfsrb/events/Pages/March-21%202023-State-Board-Meeting.aspx",
"https://www2.illinois.gov/sites/hfsrb/events/Pages/May-9-2023-State-Board-Meeting.aspx",
"https://www2.illinois.gov/sites/hfsrb/events/Pages/June-27-2023%20State%20Board%20Meeting.aspx",
"https://www2.illinois.gov/sites/hfsrb/events/Pages/August-15-2023-State-Board-Meeting.aspx",
"https://www2.illinois.gov/sites/hfsrb/events/Pages/October-3-2023-State-Board-Meeting.aspx",
"https://www2.illinois.gov/sites/hfsrb/events/Pages/December-5-2023%20State%20Board%20Meeting.aspx",
"https://www2.illinois.gov/sites/hfsrb/events/Pages/March-21%202023-State-Board-Meeting.aspx", # noqa
"https://www2.illinois.gov/sites/hfsrb/events/Pages/May-9-2023-State-Board-Meeting.aspx", # noqa
"https://www2.illinois.gov/sites/hfsrb/events/Pages/June-27-2023%20State%20Board%20Meeting.aspx", # noqa
"https://www2.illinois.gov/sites/hfsrb/events/Pages/August-15-2023-State-Board-Meeting.aspx", # noqa
"https://www2.illinois.gov/sites/hfsrb/events/Pages/October-3-2023-State-Board-Meeting.aspx", # noqa
"https://www2.illinois.gov/sites/hfsrb/events/Pages/December-5-2023%20State%20Board%20Meeting.aspx", # noqa
]


def mock_scrapy_request(link, callback):

with open(
join(dirname(__file__), "files", "il_health_facilities_helper.html"), "rb"
) as f:
Expand All @@ -46,7 +46,6 @@ def mock_scrapy_request(link, callback):

@patch("scrapy.http.Request", mock_scrapy_request)
def generate_parsed_items():

freezer = freeze_time("2023-02-09")
freezer.start()

Expand All @@ -65,19 +64,16 @@ def test_num_meetings_found():

@pytest.mark.parametrize("item", parsed_items)
def test_title(item):

assert item["title"] == "March 21, 2023 State Board Meeting"


@pytest.mark.parametrize("item", parsed_items)
def test_description(item):

assert item["description"] == ""


@pytest.mark.parametrize("item", parsed_items)
def test_start(item):

assert item["start"].strftime("%Y_%B_%d_%I_%M_%p") == "2023_March_21_09_00_AM"


Expand All @@ -88,7 +84,6 @@ def test_end(item):

@pytest.mark.parametrize("item", parsed_items)
def test_time_notes(item):

assert item["time_notes"] == ""


Expand Down Expand Up @@ -124,15 +119,15 @@ def test_source(item):
def test_links(item):
assert item["links"] == [
{
"href": "https://www2.illinois.gov/sites/hfsrb/events/Pages/Board-Meetings.aspx",
"href": "https://www2.illinois.gov/sites/hfsrb/events/Pages/Board-Meetings.aspx", # noqa
"title": "Board and Subcommittee Meetings",
},
{
"href": "https://www2.illinois.gov/sites/hfsrb/events/Pages/Previous-Meetings.aspx",
"href": "https://www2.illinois.gov/sites/hfsrb/events/Pages/Previous-Meetings.aspx", # noqa
"title": "Previous Meeting",
},
{
"href": "https://www2.illinois.gov/sites/hfsrb/events/Pages/Public-Hearing.aspx",
"href": "https://www2.illinois.gov/sites/hfsrb/events/Pages/Public-Hearing.aspx", # noqa
"title": "Public Hearings",
},
]
Expand Down
3 changes: 2 additions & 1 deletion tests/test_il_procurement_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ def test_all_day(item):
# previous meeting minutes
prev_url = "https://www2.illinois.gov/sites/ppb/Pages/board_minutes.aspx"
test_response2 = file_response(
join(dirname(__file__), "files", "il_procurement_policy_prev.html"), url=prev_url,
join(dirname(__file__), "files", "il_procurement_policy_prev.html"),
url=prev_url,
)
parsed_items_prev = sorted(
[item for item in spider._prev_meetings(test_response2)], key=itemgetter("start")
Expand Down

0 comments on commit d7eeb7a

Please sign in to comment.