py4quality 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. py4quality-0.1.0/PKG-INFO +129 -0
  2. py4quality-0.1.0/README.md +116 -0
  3. py4quality-0.1.0/pyproject.toml +22 -0
  4. py4quality-0.1.0/setup.cfg +4 -0
  5. py4quality-0.1.0/src/py4quality.egg-info/PKG-INFO +129 -0
  6. py4quality-0.1.0/src/py4quality.egg-info/SOURCES.txt +62 -0
  7. py4quality-0.1.0/src/py4quality.egg-info/dependency_links.txt +1 -0
  8. py4quality-0.1.0/src/py4quality.egg-info/requires.txt +2 -0
  9. py4quality-0.1.0/src/py4quality.egg-info/top_level.txt +1 -0
  10. py4quality-0.1.0/src/pyquality/__init__.py +15 -0
  11. py4quality-0.1.0/src/pyquality/api.py +59 -0
  12. py4quality-0.1.0/src/pyquality/browser.py +179 -0
  13. py4quality-0.1.0/src/pyquality/cdp_driver.py +126 -0
  14. py4quality-0.1.0/src/pyquality/domains/__init__.py +50 -0
  15. py4quality-0.1.0/src/pyquality/domains/accessibility.py +114 -0
  16. py4quality-0.1.0/src/pyquality/domains/animation.py +96 -0
  17. py4quality-0.1.0/src/pyquality/domains/audits.py +42 -0
  18. py4quality-0.1.0/src/pyquality/domains/autofill.py +45 -0
  19. py4quality-0.1.0/src/pyquality/domains/backgroundservice.py +42 -0
  20. py4quality-0.1.0/src/pyquality/domains/bluetoothemulation.py +171 -0
  21. py4quality-0.1.0/src/pyquality/domains/browser.py +242 -0
  22. py4quality-0.1.0/src/pyquality/domains/cachestorage.py +72 -0
  23. py4quality-0.1.0/src/pyquality/domains/cast.py +57 -0
  24. py4quality-0.1.0/src/pyquality/domains/css.py +409 -0
  25. py4quality-0.1.0/src/pyquality/domains/deviceaccess.py +38 -0
  26. py4quality-0.1.0/src/pyquality/domains/deviceorientation.py +24 -0
  27. py4quality-0.1.0/src/pyquality/domains/dom.py +641 -0
  28. py4quality-0.1.0/src/pyquality/domains/domdebugger.py +113 -0
  29. py4quality-0.1.0/src/pyquality/domains/domsnapshot.py +61 -0
  30. py4quality-0.1.0/src/pyquality/domains/domstorage.py +60 -0
  31. py4quality-0.1.0/src/pyquality/domains/emulation.py +610 -0
  32. py4quality-0.1.0/src/pyquality/domains/eventbreakpoints.py +29 -0
  33. py4quality-0.1.0/src/pyquality/domains/extensions.py +94 -0
  34. py4quality-0.1.0/src/pyquality/domains/fedcm.py +77 -0
  35. py4quality-0.1.0/src/pyquality/domains/fetch.py +147 -0
  36. py4quality-0.1.0/src/pyquality/domains/filesystem.py +13 -0
  37. py4quality-0.1.0/src/pyquality/domains/headlessexperimental.py +43 -0
  38. py4quality-0.1.0/src/pyquality/domains/indexeddb.py +169 -0
  39. py4quality-0.1.0/src/pyquality/domains/input.py +327 -0
  40. py4quality-0.1.0/src/pyquality/domains/inspector.py +18 -0
  41. py4quality-0.1.0/src/pyquality/domains/io.py +38 -0
  42. py4quality-0.1.0/src/pyquality/domains/layertree.py +99 -0
  43. py4quality-0.1.0/src/pyquality/domains/log.py +41 -0
  44. py4quality-0.1.0/src/pyquality/domains/media.py +18 -0
  45. py4quality-0.1.0/src/pyquality/domains/memory.py +91 -0
  46. py4quality-0.1.0/src/pyquality/domains/network.py +518 -0
  47. py4quality-0.1.0/src/pyquality/domains/overlay.py +332 -0
  48. py4quality-0.1.0/src/pyquality/domains/page.py +738 -0
  49. py4quality-0.1.0/src/pyquality/domains/performance.py +37 -0
  50. py4quality-0.1.0/src/pyquality/domains/performancetimeline.py +17 -0
  51. py4quality-0.1.0/src/pyquality/domains/preload.py +18 -0
  52. py4quality-0.1.0/src/pyquality/domains/pwa.py +94 -0
  53. py4quality-0.1.0/src/pyquality/domains/security.py +47 -0
  54. py4quality-0.1.0/src/pyquality/domains/serviceworker.py +120 -0
  55. py4quality-0.1.0/src/pyquality/domains/smartcardemulation.py +134 -0
  56. py4quality-0.1.0/src/pyquality/domains/storage.py +377 -0
  57. py4quality-0.1.0/src/pyquality/domains/systeminfo.py +27 -0
  58. py4quality-0.1.0/src/pyquality/domains/target.py +280 -0
  59. py4quality-0.1.0/src/pyquality/domains/tethering.py +22 -0
  60. py4quality-0.1.0/src/pyquality/domains/tracing.py +86 -0
  61. py4quality-0.1.0/src/pyquality/domains/webaudio.py +27 -0
  62. py4quality-0.1.0/src/pyquality/domains/webauthn.py +154 -0
  63. py4quality-0.1.0/src/pyquality/domains/webmcp.py +11 -0
  64. py4quality-0.1.0/src/pyquality/generate_cdp_wrappers.py +83 -0
@@ -0,0 +1,129 @@
1
+ Metadata-Version: 2.4
2
+ Name: py4quality
3
+ Version: 0.1.0
4
+ Summary: A highly user-friendly, kid-friendly automation framework using Chrome DevTools Protocol (CDP).
5
+ Author: Venkata Santosh Tharigoppala
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/santoshtvk-new/Pyquality
8
+ Project-URL: Bug Tracker, https://github.com/santoshtvk-new/Pyquality/issues
9
+ Requires-Python: >=3.8
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: websocket-client>=1.6.1
12
+ Requires-Dist: requests>=2.31.0
13
+
14
+ # pyquality 🎈
15
+
16
+ A kid-friendly, yet exceptionally powerful automation framework for Python driven directly by the Chrome DevTools Protocol (CDP).
17
+
18
+ `pyquality` is designed to be as simple as possible. Want to close the browser? Just call `b.bye()`. Want to navigate? `b.go_to("https://...")`
19
+
20
+ Under the hood, it retains uncompromising power. Advanced users have **unfiltered access** to all 40+ raw Chromium DevTools domains (DOM, Network, Page, etc.) auto-generated from the official Google spec!
21
+
22
+ ---
23
+
24
+ ## 🚀 Installation (Source)
25
+ If you are developing locally:
26
+ ```bash
27
+ git clone https://github.com/santoshtvk-new/Pyquality.git
28
+ cd pyquality
29
+ pip install -e .
30
+ ```
31
+
32
+ ## 🛠️ Installation (PIP)
33
+ *(When published to PyPi)*
34
+ ```bash
35
+ pip install pyquality
36
+ ```
37
+
38
+ ---
39
+
40
+ ## 📖 Quick Start
41
+
42
+ ```python
43
+ from pyquality.browser import Browser
44
+
45
+ # 1. Start it up
46
+ b = Browser(headless=False)
47
+
48
+ # 2. Go somewhere
49
+ b.go_to("https://example.com")
50
+
51
+ # 3. Validation is easy
52
+ b.should_be_seen("h1")
53
+
54
+ # 4. Say goodbye
55
+ b.bye()
56
+ ```
57
+
58
+ ## ✨ The Kid-Friendly Aliases
59
+
60
+ `pyquality` dynamically binds methods defined in `METHOD_ALIASES.yml` so you can use vocabulary that makes sense to you.
61
+
62
+ ### Navigation
63
+ - `navigate(url)` -> `go_to`, `open_website`
64
+ - `reload()` -> `refresh`, `reload_page`
65
+ - `close()` -> `close_browser`, `bye`
66
+ - `go_back()` -> `step_back`, `previous_page`
67
+ - `go_forward()` -> `step_forward`, `next_page`
68
+
69
+ ### Interaction
70
+ - `click_element(selector)` -> `click_this`, `tap`
71
+ - `type_text(selector, text)` -> `type_in`, `write_this`
72
+ - `hover_element(selector)` -> `point_at`, `hover_over`
73
+
74
+ ### APIs & Data
75
+ - `API.get(endpoint)` -> `fetch_data`, `grab`
76
+ - `API.post(endpoint, json)` -> `create_data`, `send_new`
77
+
78
+ ---
79
+
80
+ ## ⚡ Raw CDP Power (Advanced)
81
+
82
+ If you need capabilities beyond the simple wrappers, `pyquality` has raw auto-generated bindings for **EVERY** CDP Domain. They are attached natively to the browser instance:
83
+
84
+ ```python
85
+ from pyquality.browser import Browser
86
+ b = Browser()
87
+
88
+ # Use raw 'Page' domain to capture a PDF
89
+ b.page.printToPDF()
90
+
91
+ # Use raw 'Network' domain to throttle connection
92
+ b.network.emulateNetworkConditions(
93
+ offline=False,
94
+ latency=200,
95
+ downloadThroughput=1000,
96
+ uploadThroughput=1000
97
+ )
98
+
99
+ # Use raw 'DOM' domain to get node information
100
+ b.dom.getDocument(depth=-1)
101
+ ```
102
+
103
+ ## 📦 Deploying Initial PIP Package
104
+
105
+ To package this framework and upload it to PyPi:
106
+
107
+ 1. **Install build tools:**
108
+ ```bash
109
+ pip install build twine
110
+ ```
111
+
112
+ 2. **Generate Native Wrappers:**
113
+ Ensure your CDP protocol bindings are up-to-date:
114
+ ```bash
115
+ python src/pyquality/generate_cdp_wrappers.py
116
+ ```
117
+
118
+ 3. **Build wheels:**
119
+ ```bash
120
+ python -m build
121
+ ```
122
+ *This generates `.tar.gz` and `.whl` files in the `/dist` folder.*
123
+
124
+ 4. **Upload to PyPi (Requires Account):**
125
+ ```bash
126
+ python -m twine upload dist/*
127
+ ```
128
+
129
+ 5. **Done!** Users can now run `pip install pyquality`.
@@ -0,0 +1,116 @@
1
+ # pyquality 🎈
2
+
3
+ A kid-friendly, yet exceptionally powerful automation framework for Python driven directly by the Chrome DevTools Protocol (CDP).
4
+
5
+ `pyquality` is designed to be as simple as possible. Want to close the browser? Just call `b.bye()`. Want to navigate? `b.go_to("https://...")`
6
+
7
+ Under the hood, it retains uncompromising power. Advanced users have **unfiltered access** to all 40+ raw Chromium DevTools domains (DOM, Network, Page, etc.) auto-generated from the official Google spec!
8
+
9
+ ---
10
+
11
+ ## 🚀 Installation (Source)
12
+ If you are developing locally:
13
+ ```bash
14
+ git clone https://github.com/santoshtvk-new/Pyquality.git
15
+ cd pyquality
16
+ pip install -e .
17
+ ```
18
+
19
+ ## 🛠️ Installation (PIP)
20
+ *(When published to PyPi)*
21
+ ```bash
22
+ pip install pyquality
23
+ ```
24
+
25
+ ---
26
+
27
+ ## 📖 Quick Start
28
+
29
+ ```python
30
+ from pyquality.browser import Browser
31
+
32
+ # 1. Start it up
33
+ b = Browser(headless=False)
34
+
35
+ # 2. Go somewhere
36
+ b.go_to("https://example.com")
37
+
38
+ # 3. Validation is easy
39
+ b.should_be_seen("h1")
40
+
41
+ # 4. Say goodbye
42
+ b.bye()
43
+ ```
44
+
45
+ ## ✨ The Kid-Friendly Aliases
46
+
47
+ `pyquality` dynamically binds methods defined in `METHOD_ALIASES.yml` so you can use vocabulary that makes sense to you.
48
+
49
+ ### Navigation
50
+ - `navigate(url)` -> `go_to`, `open_website`
51
+ - `reload()` -> `refresh`, `reload_page`
52
+ - `close()` -> `close_browser`, `bye`
53
+ - `go_back()` -> `step_back`, `previous_page`
54
+ - `go_forward()` -> `step_forward`, `next_page`
55
+
56
+ ### Interaction
57
+ - `click_element(selector)` -> `click_this`, `tap`
58
+ - `type_text(selector, text)` -> `type_in`, `write_this`
59
+ - `hover_element(selector)` -> `point_at`, `hover_over`
60
+
61
+ ### APIs & Data
62
+ - `API.get(endpoint)` -> `fetch_data`, `grab`
63
+ - `API.post(endpoint, json)` -> `create_data`, `send_new`
64
+
65
+ ---
66
+
67
+ ## ⚡ Raw CDP Power (Advanced)
68
+
69
+ If you need capabilities beyond the simple wrappers, `pyquality` has raw auto-generated bindings for **EVERY** CDP Domain. They are attached natively to the browser instance:
70
+
71
+ ```python
72
+ from pyquality.browser import Browser
73
+ b = Browser()
74
+
75
+ # Use raw 'Page' domain to capture a PDF
76
+ b.page.printToPDF()
77
+
78
+ # Use raw 'Network' domain to throttle connection
79
+ b.network.emulateNetworkConditions(
80
+ offline=False,
81
+ latency=200,
82
+ downloadThroughput=1000,
83
+ uploadThroughput=1000
84
+ )
85
+
86
+ # Use raw 'DOM' domain to get node information
87
+ b.dom.getDocument(depth=-1)
88
+ ```
89
+
90
+ ## 📦 Deploying Initial PIP Package
91
+
92
+ To package this framework and upload it to PyPi:
93
+
94
+ 1. **Install build tools:**
95
+ ```bash
96
+ pip install build twine
97
+ ```
98
+
99
+ 2. **Generate Native Wrappers:**
100
+ Ensure your CDP protocol bindings are up-to-date:
101
+ ```bash
102
+ python src/pyquality/generate_cdp_wrappers.py
103
+ ```
104
+
105
+ 3. **Build wheels:**
106
+ ```bash
107
+ python -m build
108
+ ```
109
+ *This generates `.tar.gz` and `.whl` files in the `/dist` folder.*
110
+
111
+ 4. **Upload to PyPi (Requires Account):**
112
+ ```bash
113
+ python -m twine upload dist/*
114
+ ```
115
+
116
+ 5. **Done!** Users can now run `pip install pyquality`.
@@ -0,0 +1,22 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "py4quality"
7
+ version = "0.1.0"
8
+ description = "A highly user-friendly, kid-friendly automation framework using Chrome DevTools Protocol (CDP)."
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = { text = "MIT" }
12
+ authors = [
13
+ { name="Venkata Santosh Tharigoppala" }
14
+ ]
15
+ dependencies = [
16
+ "websocket-client>=1.6.1",
17
+ "requests>=2.31.0"
18
+ ]
19
+
20
+ [project.urls]
21
+ "Homepage" = "https://github.com/santoshtvk-new/Pyquality"
22
+ "Bug Tracker" = "https://github.com/santoshtvk-new/Pyquality/issues"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,129 @@
1
+ Metadata-Version: 2.4
2
+ Name: py4quality
3
+ Version: 0.1.0
4
+ Summary: A highly user-friendly, kid-friendly automation framework using Chrome DevTools Protocol (CDP).
5
+ Author: Venkata Santosh Tharigoppala
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/santoshtvk-new/Pyquality
8
+ Project-URL: Bug Tracker, https://github.com/santoshtvk-new/Pyquality/issues
9
+ Requires-Python: >=3.8
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: websocket-client>=1.6.1
12
+ Requires-Dist: requests>=2.31.0
13
+
14
+ # pyquality 🎈
15
+
16
+ A kid-friendly, yet exceptionally powerful automation framework for Python driven directly by the Chrome DevTools Protocol (CDP).
17
+
18
+ `pyquality` is designed to be as simple as possible. Want to close the browser? Just call `b.bye()`. Want to navigate? `b.go_to("https://...")`
19
+
20
+ Under the hood, it retains uncompromising power. Advanced users have **unfiltered access** to all 40+ raw Chromium DevTools domains (DOM, Network, Page, etc.) auto-generated from the official Google spec!
21
+
22
+ ---
23
+
24
+ ## 🚀 Installation (Source)
25
+ If you are developing locally:
26
+ ```bash
27
+ git clone https://github.com/santoshtvk-new/Pyquality.git
28
+ cd pyquality
29
+ pip install -e .
30
+ ```
31
+
32
+ ## 🛠️ Installation (PIP)
33
+ *(When published to PyPi)*
34
+ ```bash
35
+ pip install pyquality
36
+ ```
37
+
38
+ ---
39
+
40
+ ## 📖 Quick Start
41
+
42
+ ```python
43
+ from pyquality.browser import Browser
44
+
45
+ # 1. Start it up
46
+ b = Browser(headless=False)
47
+
48
+ # 2. Go somewhere
49
+ b.go_to("https://example.com")
50
+
51
+ # 3. Validation is easy
52
+ b.should_be_seen("h1")
53
+
54
+ # 4. Say goodbye
55
+ b.bye()
56
+ ```
57
+
58
+ ## ✨ The Kid-Friendly Aliases
59
+
60
+ `pyquality` dynamically binds methods defined in `METHOD_ALIASES.yml` so you can use vocabulary that makes sense to you.
61
+
62
+ ### Navigation
63
+ - `navigate(url)` -> `go_to`, `open_website`
64
+ - `reload()` -> `refresh`, `reload_page`
65
+ - `close()` -> `close_browser`, `bye`
66
+ - `go_back()` -> `step_back`, `previous_page`
67
+ - `go_forward()` -> `step_forward`, `next_page`
68
+
69
+ ### Interaction
70
+ - `click_element(selector)` -> `click_this`, `tap`
71
+ - `type_text(selector, text)` -> `type_in`, `write_this`
72
+ - `hover_element(selector)` -> `point_at`, `hover_over`
73
+
74
+ ### APIs & Data
75
+ - `API.get(endpoint)` -> `fetch_data`, `grab`
76
+ - `API.post(endpoint, json)` -> `create_data`, `send_new`
77
+
78
+ ---
79
+
80
+ ## ⚡ Raw CDP Power (Advanced)
81
+
82
+ If you need capabilities beyond the simple wrappers, `pyquality` has raw auto-generated bindings for **EVERY** CDP Domain. They are attached natively to the browser instance:
83
+
84
+ ```python
85
+ from pyquality.browser import Browser
86
+ b = Browser()
87
+
88
+ # Use raw 'Page' domain to capture a PDF
89
+ b.page.printToPDF()
90
+
91
+ # Use raw 'Network' domain to throttle connection
92
+ b.network.emulateNetworkConditions(
93
+ offline=False,
94
+ latency=200,
95
+ downloadThroughput=1000,
96
+ uploadThroughput=1000
97
+ )
98
+
99
+ # Use raw 'DOM' domain to get node information
100
+ b.dom.getDocument(depth=-1)
101
+ ```
102
+
103
+ ## 📦 Deploying Initial PIP Package
104
+
105
+ To package this framework and upload it to PyPi:
106
+
107
+ 1. **Install build tools:**
108
+ ```bash
109
+ pip install build twine
110
+ ```
111
+
112
+ 2. **Generate Native Wrappers:**
113
+ Ensure your CDP protocol bindings are up-to-date:
114
+ ```bash
115
+ python src/pyquality/generate_cdp_wrappers.py
116
+ ```
117
+
118
+ 3. **Build wheels:**
119
+ ```bash
120
+ python -m build
121
+ ```
122
+ *This generates `.tar.gz` and `.whl` files in the `/dist` folder.*
123
+
124
+ 4. **Upload to PyPi (Requires Account):**
125
+ ```bash
126
+ python -m twine upload dist/*
127
+ ```
128
+
129
+ 5. **Done!** Users can now run `pip install pyquality`.
@@ -0,0 +1,62 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/py4quality.egg-info/PKG-INFO
4
+ src/py4quality.egg-info/SOURCES.txt
5
+ src/py4quality.egg-info/dependency_links.txt
6
+ src/py4quality.egg-info/requires.txt
7
+ src/py4quality.egg-info/top_level.txt
8
+ src/pyquality/__init__.py
9
+ src/pyquality/api.py
10
+ src/pyquality/browser.py
11
+ src/pyquality/cdp_driver.py
12
+ src/pyquality/generate_cdp_wrappers.py
13
+ src/pyquality/domains/__init__.py
14
+ src/pyquality/domains/accessibility.py
15
+ src/pyquality/domains/animation.py
16
+ src/pyquality/domains/audits.py
17
+ src/pyquality/domains/autofill.py
18
+ src/pyquality/domains/backgroundservice.py
19
+ src/pyquality/domains/bluetoothemulation.py
20
+ src/pyquality/domains/browser.py
21
+ src/pyquality/domains/cachestorage.py
22
+ src/pyquality/domains/cast.py
23
+ src/pyquality/domains/css.py
24
+ src/pyquality/domains/deviceaccess.py
25
+ src/pyquality/domains/deviceorientation.py
26
+ src/pyquality/domains/dom.py
27
+ src/pyquality/domains/domdebugger.py
28
+ src/pyquality/domains/domsnapshot.py
29
+ src/pyquality/domains/domstorage.py
30
+ src/pyquality/domains/emulation.py
31
+ src/pyquality/domains/eventbreakpoints.py
32
+ src/pyquality/domains/extensions.py
33
+ src/pyquality/domains/fedcm.py
34
+ src/pyquality/domains/fetch.py
35
+ src/pyquality/domains/filesystem.py
36
+ src/pyquality/domains/headlessexperimental.py
37
+ src/pyquality/domains/indexeddb.py
38
+ src/pyquality/domains/input.py
39
+ src/pyquality/domains/inspector.py
40
+ src/pyquality/domains/io.py
41
+ src/pyquality/domains/layertree.py
42
+ src/pyquality/domains/log.py
43
+ src/pyquality/domains/media.py
44
+ src/pyquality/domains/memory.py
45
+ src/pyquality/domains/network.py
46
+ src/pyquality/domains/overlay.py
47
+ src/pyquality/domains/page.py
48
+ src/pyquality/domains/performance.py
49
+ src/pyquality/domains/performancetimeline.py
50
+ src/pyquality/domains/preload.py
51
+ src/pyquality/domains/pwa.py
52
+ src/pyquality/domains/security.py
53
+ src/pyquality/domains/serviceworker.py
54
+ src/pyquality/domains/smartcardemulation.py
55
+ src/pyquality/domains/storage.py
56
+ src/pyquality/domains/systeminfo.py
57
+ src/pyquality/domains/target.py
58
+ src/pyquality/domains/tethering.py
59
+ src/pyquality/domains/tracing.py
60
+ src/pyquality/domains/webaudio.py
61
+ src/pyquality/domains/webauthn.py
62
+ src/pyquality/domains/webmcp.py
@@ -0,0 +1,2 @@
1
+ websocket-client>=1.6.1
2
+ requests>=2.31.0
@@ -0,0 +1 @@
1
+ pyquality
@@ -0,0 +1,15 @@
1
+ import yaml
2
+ import os
3
+
4
+ def load_aliases():
5
+ alias_path = os.path.join(os.path.dirname(__file__), "..", "..", "METHOD_ALIASES.yml")
6
+ if not os.path.exists(alias_path):
7
+ return {}
8
+ with open(alias_path, 'r') as f:
9
+ return yaml.safe_load(f)
10
+
11
+ # The loaded aliases can be used by the browser instance to dynamically map methods.
12
+ ALIASES = load_aliases()
13
+
14
+ from .api import API
15
+ __version__ = "0.1.0"
@@ -0,0 +1,59 @@
1
+ import requests
2
+
3
+ class API:
4
+ """
5
+ Kid-friendly wrapper for REST API calls.
6
+ """
7
+ def __init__(self, base_url=""):
8
+ self.base_url = base_url
9
+ self.session = requests.Session()
10
+ self._apply_aliases()
11
+
12
+ def _apply_aliases(self):
13
+ """Bind kid-friendly aliases to instance methods dynamically."""
14
+ from .__init__ import ALIASES
15
+ if "api" in ALIASES:
16
+ for method_name, aliases in ALIASES["api"].items():
17
+ if hasattr(self, method_name):
18
+ func = getattr(self, method_name)
19
+ for alias in aliases:
20
+ setattr(self, alias, func)
21
+
22
+ def _build_url(self, endpoint):
23
+ if endpoint.startswith("http"):
24
+ return endpoint
25
+ return f"{self.base_url.rstrip('/')}/{endpoint.lstrip('/')}"
26
+
27
+ def set_header(self, key, value):
28
+ """Set a header for subsequent requests."""
29
+ self.session.headers.update({key: value})
30
+
31
+ def use_token(self, token):
32
+ """Authenticate with a Bearer token."""
33
+ self.set_header("Authorization", f"Bearer {token}")
34
+
35
+ def get(self, endpoint, **kwargs):
36
+ """Send a GET request."""
37
+ return self.session.get(self._build_url(endpoint), **kwargs)
38
+
39
+ def post(self, endpoint, json=None, data=None, **kwargs):
40
+ """Send a POST request."""
41
+ return self.session.post(self._build_url(endpoint), json=json, data=data, **kwargs)
42
+
43
+ def put(self, endpoint, json=None, data=None, **kwargs):
44
+ """Send a PUT request."""
45
+ return self.session.put(self._build_url(endpoint), json=json, data=data, **kwargs)
46
+
47
+ def delete(self, endpoint, **kwargs):
48
+ """Send a DELETE request."""
49
+ return self.session.delete(self._build_url(endpoint), **kwargs)
50
+
51
+ def patch(self, endpoint, json=None, data=None, **kwargs):
52
+ """Send a PATCH request."""
53
+ return self.session.patch(self._build_url(endpoint), json=json, data=data, **kwargs)
54
+
55
+ def should_be_status(self, response, expected_status):
56
+ """Kid-friendly assertion for status codes."""
57
+ if response.status_code != expected_status:
58
+ raise AssertionError(f"Expected status {expected_status}, but got {response.status_code}.")
59
+ return True