Skip to content

Commit 0a49d98

Browse files
authored
Add another test case (#91)
1 parent 6b287e5 commit 0a49d98

File tree

3 files changed

+72
-1
lines changed

3 files changed

+72
-1
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
Accept:
6+
- '*/*'
7+
Accept-Encoding:
8+
- gzip, deflate
9+
Connection:
10+
- keep-alive
11+
User-Agent:
12+
- python-requests/2.31.0
13+
method: GET
14+
uri: https://example.org/
15+
response:
16+
body:
17+
string: !!binary |
18+
H4sIAMIVqF0AA31UTXPbIBC9+1ds1UsyIyQnaRqPLWn6mWkPaQ9pDz0SsbKYCFAByfZ08t+7Qo4j
19+
N5makYFdeLvvsZC9Eqb0uxah9qopZtljh1wUM6Bf5qVvsPi85aptED4ZxaXO0tE6G5co9BzKmluH
20+
Po86X7FFBGkxcdbetwx/d7LPo49Ge9SeDWEjKMdZHnnc+nQIvzpAvYSkucI86iVuWmP9ZP9GCl/n
21+
AntZIguTGKSWXvKGuZI3mJ89QTm/IzJDBvvApXPR6LszYgd/wjBMeXm/tqbTgpWmMXYJr6s5tfPV
22+
YYnidi31EuZPppYLIfX6yFZRpqziSja7JTDekpzM7ZxHFcPYs07G8KGR+v6Gl7fBdE2bYohucW0Q
23+
fn6NaPy9RQ23XLth8gWbHr0sOXzDDslyMMTw3hJ3wqalzKGV1VMuYfAQ/oXsJ3SDcEt4O5+32+cM
24+
L1EB77x5geg5qtV/RRPUJhncGSvQMsuF7BzplFweAZgtczUXZkPI7RYu6Luibxjb9R0/mcehJfPz
25+
09WEDF8O6sXU99JJj2JC7TGTi8WbxWKSyXD+TGBpLPfSEEttNE5B3ykUksOJ4lu21+dq0Od0An6s
26+
4lFV/KPYROVjx8MkZJaGCi3CWWXpeB1n2VCbdDsp2L6O67NnN5NMo68tftTSgQh2oFFlLHQOYZg1
27+
Tef8QLhHwBHBDQ56DjpF98kl8Mt0RGIXtnhCGqtlj6ahIXkJoLNIdHxtOg+tlRSiNHS0Ugcxgebc
28+
3VOFhOgtWiWdI0eSpe0hz4weCItVHg3PhFum6WazSSTXPDF2nY4hXbpPMypujB1IEKAKQZKE0HgR
29+
ELM0iJOle6nS8UH7CyjrfG/oBAAA
30+
headers:
31+
Accept-Ranges:
32+
- bytes
33+
Age:
34+
- '327361'
35+
Cache-Control:
36+
- max-age=604800
37+
Content-Encoding:
38+
- gzip
39+
Content-Length:
40+
- '648'
41+
Content-Type:
42+
- text/html; charset=UTF-8
43+
Date:
44+
- Sat, 11 Nov 2023 21:14:24 GMT
45+
Etag:
46+
- '"3147526947+gzip"'
47+
Expires:
48+
- Sat, 18 Nov 2023 21:14:24 GMT
49+
Last-Modified:
50+
- Thu, 17 Oct 2019 07:18:26 GMT
51+
Server:
52+
- ECS (dcb/7EA3)
53+
Vary:
54+
- Accept-Encoding
55+
X-Cache:
56+
- HIT
57+
status:
58+
code: 200
59+
message: OK
60+
version: 1

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ vcrpy = "^5.1.0"
2828
[tool.ruff]
2929
ignore = ["E501"]
3030

31+
[tool.isort]
32+
profile = "black"
33+
3134
[build-system]
3235
requires = ["poetry-core>=1.0.0"]
3336
build-backend = "poetry.core.masonry.api"

tests/test_scraper.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import pytest
44
import vcr
55

6-
from cert_host_scraper.scraper import Options, fetch_urls
6+
from cert_host_scraper.scraper import Options, fetch_site_information, fetch_urls
7+
8+
TIMEOUT = 2
79

810

911
class TestScraper(TestCase):
@@ -13,3 +15,9 @@ def test_fetch_urls_clean(self):
1315
results = fetch_urls("example.org", Options(timeout=2, clean=True))
1416
self.assertEqual(4, len(results))
1517
self.assertIn("https://www.example.org", results)
18+
19+
@pytest.mark.enable_socket
20+
@vcr.use_cassette("fixtures/vcr/fetch_site_information_valid.yaml")
21+
def test_fetch_site_information_valid(self):
22+
result = fetch_site_information("https://example.org", TIMEOUT)
23+
self.assertEqual(200, result)

0 commit comments

Comments
 (0)