Skip to content

Commit

Permalink
Rename the http_client variable to http (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
BurnzZ authored Aug 26, 2022
1 parent 6d83ffb commit 7ac5fbe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions docs/intro/advanced-tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Suppose we have the following Page Object:
@attr.define
class ProductPage(web_poet.ItemWebPage):
http_client: web_poet.HttpClient
http: web_poet.HttpClient
async def to_item(self):
item = {
Expand All @@ -59,7 +59,7 @@ Suppose we have the following Page Object:
}
# Simulates clicking on a button that says "View All Images"
response: web_poet.HttpResponse = await self.http_client.get(
response: web_poet.HttpResponse = await self.http.get(
f"https://api.example.com/v2/images?id={item['product_id']}"
)
item["images"] = response.css(".product-images img::attr(src)").getall()
Expand Down Expand Up @@ -111,7 +111,7 @@ This basically acts as a switch to update the behavior of the Page Object:
@attr.define
class ProductPage(web_poet.ItemWebPage):
http_client: web_poet.HttpClient
http: web_poet.HttpClient
page_params: web_poet.PageParams
async def to_item(self):
Expand All @@ -123,7 +123,7 @@ This basically acts as a switch to update the behavior of the Page Object:
# Simulates clicking on a button that says "View All Images"
if self.page_params.get("enable_extracting_all_images")
response: web_poet.HttpResponse = await self.http_client.get(
response: web_poet.HttpResponse = await self.http.get(
f"https://api.example.com/v2/images?id={item['product_id']}"
)
item["images"] = response.css(".product-images img::attr(src)").getall()
Expand Down
26 changes: 13 additions & 13 deletions tests/test_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ def test_additional_requests_success():

@attr.define
class ItemPage(ItemWebPage):
http_client: HttpClient
http: HttpClient

async def to_item(self):
response = await self.http_client.request(
response = await self.http.request(
server.root_url,
body=b"bar",
)
Expand Down Expand Up @@ -171,11 +171,11 @@ def test_additional_requests_bad_response():

@attr.define
class ItemPage(ItemWebPage):
http_client: HttpClient
http: HttpClient

async def to_item(self):
try:
await self.http_client.request(
await self.http.request(
server.root_url,
body=b"400",
)
Expand Down Expand Up @@ -218,11 +218,11 @@ def test_additional_requests_connection_issue():

@attr.define
class ItemPage(ItemWebPage):
http_client: HttpClient
http: HttpClient

async def to_item(self):
try:
await self.http_client.request(
await self.http.request(
server.root_url,
body=b"0.002",
)
Expand Down Expand Up @@ -257,11 +257,11 @@ def test_additional_requests_ignored_request():

@attr.define
class ItemPage(ItemWebPage):
http_client: HttpClient
http: HttpClient

async def to_item(self):
try:
await self.http_client.request(
await self.http.request(
server.root_url,
body=b"ignore",
)
Expand Down Expand Up @@ -314,11 +314,11 @@ def test_additional_requests_unhandled_downloader_middleware_exception():

@attr.define
class ItemPage(ItemWebPage):
http_client: HttpClient
http: HttpClient

async def to_item(self):
try:
await self.http_client.request(
await self.http.request(
server.root_url,
body=b"raise",
)
Expand Down Expand Up @@ -368,14 +368,14 @@ def test_additional_requests_dont_filter():

@attr.define
class ItemPage(ItemWebPage):
http_client: HttpClient
http: HttpClient

async def to_item(self):
response1 = await self.http_client.request(
response1 = await self.http.request(
server.root_url,
body=b"a",
)
response2 = await self.http_client.request(
response2 = await self.http.request(
server.root_url,
body=b"a",
)
Expand Down

0 comments on commit 7ac5fbe

Please sign in to comment.