Skip to content

Commit

Permalink
add 'notes' to Request
Browse files Browse the repository at this point in the history
  • Loading branch information
BurnzZ committed Jun 20, 2024
1 parent b9daff6 commit 4cddbec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,17 @@ def test_probability_request():
metadata=ProbabilityMetadata(probability=0.5),
)
assert request.get_probability() == 0.5
assert request.notes is None

request = ProbabilityRequest(
name="Get with RequestURL object",
url=RequestUrl("https://example.com/test"),
notes=["arbitrary", "info"],
)

assert request.url == "https://example.com/test"
assert request.get_probability() is None
assert request.notes == ["arbitrary", "info"]


def test_request():
Expand All @@ -154,20 +157,22 @@ def test_request():
Header(name="Content-Type", value="application/x-www-form-urlencoded"),
Header(name="Host", value="foo.example"),
]
Request(
request = Request(
name="Post Test",
url="https://example.com/test",
method="POST",
body="ZmllbGQxPXZhbHVlMSZmaWVsZDI9dmFsdWUy",
headers=headers,
)
assert request.notes is None

request = Request(
name="Get with RequestURL object",
url=RequestUrl("https://example.com/test"),
notes=["arbitrary", "info"],
)

assert request.url == "https://example.com/test"
assert request.notes == ["arbitrary", "info"]


def test_job_location():
Expand Down
3 changes: 3 additions & 0 deletions zyte_common_items/components/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class Request(Item):
#: Name of the page being requested.
name: Optional[str] = None

#: Arbitrary list of information about the request.
notes: Optional[List[str]] = None

_body_bytes = None

@property
Expand Down

0 comments on commit 4cddbec

Please sign in to comment.