返回 last30days-skill
test_linkedin_profile_base_url.py
根目录 / tests / test_linkedin_profile_base_url.py
1 """Regression: the person-run profile read must honor SCRAPECREATORS_BASE_URL."""
2
3 import unittest
4 from unittest import mock
5
6 from lib import linkedin
7
8
9 class TestReadProfileBaseUrl(unittest.TestCase):
10 def test_read_profile_uses_the_configured_base_url(self):
11 with mock.patch.dict("os.environ", {"SCRAPECREATORS_BASE_URL": "https://sc-proxy.corp.example"}), \
12 mock.patch.object(
13 linkedin.http, "get",
14 return_value={"success": True, "data": {}},
15 ) as get:
16 result = linkedin.read_profile(
17 "https://www.linkedin.com/in/dana-okafor", "fake-token",
18 )
19
20 self.assertEqual(result["status"], "ok")
21 self.assertEqual(
22 get.call_args.args[0],
23 "https://sc-proxy.corp.example/v1/linkedin/profile",
24 )
25
26 def test_read_profile_keeps_the_default_host_without_an_override(self):
27 with mock.patch.dict("os.environ", {}, clear=False), \
28 mock.patch.dict("os.environ", {}, clear=True), \
29 mock.patch.object(
30 linkedin.http, "get",
31 return_value={"success": True, "data": {}},
32 ) as get:
33 linkedin.read_profile(
34 "https://www.linkedin.com/in/dana-okafor", "fake-token",
35 )
36
37 self.assertEqual(
38 get.call_args.args[0],
39 "https://api.scrapecreators.com/v1/linkedin/profile",
40 )
41
42
43 if __name__ == "__main__":
44 unittest.main()
45
45 lines PYTHON