tcms-api 12.9.1__tar.gz → 13.2__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 (26) hide show
  1. {tcms-api-12.9.1/tcms_api.egg-info → tcms_api-13.2}/PKG-INFO +13 -1
  2. {tcms-api-12.9.1 → tcms_api-13.2}/README.rst +12 -0
  3. {tcms-api-12.9.1 → tcms_api-13.2}/tcms_api/__init__.py +49 -16
  4. tcms_api-13.2/tcms_api/version.py +1 -0
  5. {tcms-api-12.9.1 → tcms_api-13.2}/tcms_api/xmlrpc.py +3 -1
  6. {tcms-api-12.9.1 → tcms_api-13.2/tcms_api.egg-info}/PKG-INFO +13 -1
  7. tcms-api-12.9.1/tcms_api/version.py +0 -1
  8. {tcms-api-12.9.1 → tcms_api-13.2}/LICENSE +0 -0
  9. {tcms-api-12.9.1 → tcms_api-13.2}/MANIFEST.in +0 -0
  10. {tcms-api-12.9.1 → tcms_api-13.2}/requirements.txt +0 -0
  11. {tcms-api-12.9.1 → tcms_api-13.2}/setup.cfg +0 -0
  12. {tcms-api-12.9.1 → tcms_api-13.2}/setup.py +0 -0
  13. {tcms-api-12.9.1 → tcms_api-13.2}/tcms_api/plugin_helpers.py +0 -0
  14. {tcms-api-12.9.1 → tcms_api-13.2}/tcms_api.egg-info/SOURCES.txt +0 -0
  15. {tcms-api-12.9.1 → tcms_api-13.2}/tcms_api.egg-info/dependency_links.txt +0 -0
  16. {tcms-api-12.9.1 → tcms_api-13.2}/tcms_api.egg-info/requires.txt +0 -0
  17. {tcms-api-12.9.1 → tcms_api-13.2}/tcms_api.egg-info/top_level.txt +0 -0
  18. {tcms-api-12.9.1 → tcms_api-13.2}/tests/test_api_config.py +0 -0
  19. {tcms-api-12.9.1 → tcms_api-13.2}/tests/test_build.py +0 -0
  20. {tcms-api-12.9.1 → tcms_api-13.2}/tests/test_case.py +0 -0
  21. {tcms-api-12.9.1 → tcms_api-13.2}/tests/test_plan.py +0 -0
  22. {tcms-api-12.9.1 → tcms_api-13.2}/tests/test_plantype.py +0 -0
  23. {tcms-api-12.9.1 → tcms_api-13.2}/tests/test_product.py +0 -0
  24. {tcms-api-12.9.1 → tcms_api-13.2}/tests/test_run.py +0 -0
  25. {tcms-api-12.9.1 → tcms_api-13.2}/tests/test_status.py +0 -0
  26. {tcms-api-12.9.1 → tcms_api-13.2}/tests/test_version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tcms-api
3
- Version: 12.9.1
3
+ Version: 13.2
4
4
  Summary: Python API for Kiwi
5
5
  Home-page: https://github.com/kiwitcms/tcms-api
6
6
  Maintainer: Kiwi TCMS
@@ -69,6 +69,18 @@ https://tcms-api.readthedocs.io/en/latest/modules/tcms_api.html
69
69
  CHANGELOG
70
70
  ---------
71
71
 
72
+ v13.2 (27 Apr 2024)
73
+ ~~~~~~~~~~~~~~~~~~~
74
+
75
+ - Respect configuration passed as arguments to the ``TCMS()`` class, for example::
76
+
77
+ TCMS("https://kiwitcms.example.com/xml-rpc/", "api-bot", "keep-me-secret")
78
+
79
+ - Adjust usage examples and documentation for ``.exec()``. Closes
80
+ `Issue #77 <https://github.com/kiwitcms/tcms-api/issues/77>`_
81
+ - Internal changes related to testing and building this package
82
+
83
+
72
84
  v12.9.1 (13 Jan 2024)
73
85
  ~~~~~~~~~~~~~~~~~~~~~
74
86
 
@@ -40,6 +40,18 @@ https://tcms-api.readthedocs.io/en/latest/modules/tcms_api.html
40
40
  CHANGELOG
41
41
  ---------
42
42
 
43
+ v13.2 (27 Apr 2024)
44
+ ~~~~~~~~~~~~~~~~~~~
45
+
46
+ - Respect configuration passed as arguments to the ``TCMS()`` class, for example::
47
+
48
+ TCMS("https://kiwitcms.example.com/xml-rpc/", "api-bot", "keep-me-secret")
49
+
50
+ - Adjust usage examples and documentation for ``.exec()``. Closes
51
+ `Issue #77 <https://github.com/kiwitcms/tcms-api/issues/77>`_
52
+ - Internal changes related to testing and building this package
53
+
54
+
43
55
  v12.9.1 (13 Jan 2024)
44
56
  ~~~~~~~~~~~~~~~~~~~~~
45
57
 
@@ -84,11 +84,18 @@ Connect to backend::
84
84
 
85
85
  from tcms_api import TCMS
86
86
 
87
- rpc_client = TCMS()
87
+ rpc = TCMS().exec
88
88
 
89
- for test_case in rpc_client.exec.TestCase.filter({'pk': 46490}):
89
+ for test_case in rpc.TestCase.filter({'pk': 46490}):
90
90
  print(test_case)
91
91
 
92
+
93
+ After tcms-api v13.2 you can pass connection configuration directly as
94
+ arguments when initializing the TCMS() class::
95
+
96
+ TCMS("https://kiwitcms.example.com/xml-rpc/", "api-bot", "keep-me-secret").exec
97
+
98
+
92
99
  .. important::
93
100
 
94
101
  For a list of available RPC methods see
@@ -108,11 +115,13 @@ from tcms_api.xmlrpc import TCMSXmlrpc, TCMSKerbXmlrpc
108
115
 
109
116
 
110
117
  class _ConnectionProxy:
111
- def __init__(self):
118
+ def __init__(self, config):
112
119
  self.__connected_since = datetime(2024, 1, 1, 0, 0)
113
120
  self.__connection = None
121
+ self.__config = config
114
122
 
115
- def server_url(self, config):
123
+ @staticmethod
124
+ def server_url(config):
116
125
  """
117
126
  Returns the server URL and performs various sanity checks!
118
127
  """
@@ -120,23 +129,29 @@ class _ConnectionProxy:
120
129
  try:
121
130
  config["tcms"]["url"] is not None
122
131
  except (KeyError, AttributeError) as err:
123
- raise RuntimeError(f"No url found in {self._path}") from err
132
+ raise RuntimeError(f"No url found in {config}") from err
124
133
 
125
134
  return config["tcms"]["url"].replace("json-rpc", "xml-rpc")
126
135
 
127
136
  def create_connection(self):
128
- path = os.path.expanduser("~/.tcms.conf")
137
+ # try authentication credentials from Python arguments first
138
+ if self.__config["tcms"]["url"]:
139
+ config = self.__config
140
+ else:
141
+ # if not provided then try reading from the filesystem
142
+ path = os.path.expanduser("~/.tcms.conf")
129
143
 
130
- # Try system settings when the config does not exist in user directory
131
- if not os.path.exists(path):
132
- path = "/etc/tcms.conf"
133
- if not os.path.exists(path):
134
- path = "c:/tcms.conf"
135
- if not os.path.exists(path):
136
- raise RuntimeError(f"Config file '{path}' not found")
144
+ # Try system settings when the config does not exist in user directory
145
+ if not os.path.exists(path):
146
+ path = "/etc/tcms.conf"
147
+ if not os.path.exists(path):
148
+ path = "c:/tcms.conf"
137
149
 
138
- config = ConfigParser()
139
- config.read(path)
150
+ if not os.path.exists(path):
151
+ raise RuntimeError(f"Config file '{path}' not found")
152
+
153
+ config = ConfigParser()
154
+ config.read(path)
140
155
 
141
156
  rpc_implementor = None
142
157
  server_url = self.server_url(config)
@@ -187,10 +202,28 @@ class TCMS: # pylint: disable=too-few-public-methods
187
202
  parses user configuration using a utilities class!
188
203
  """
189
204
 
205
+ def __init__(self, url=None, username=None, password=None):
206
+ self.config = {
207
+ "tcms": {
208
+ "url": url,
209
+ "username": username,
210
+ "password": password,
211
+ }
212
+ }
213
+
190
214
  @property
191
215
  def exec(self):
192
216
  """
193
217
  Property that returns the underlying XML-RPC connection on which
194
218
  you can call various server-side functions.
219
+
220
+ .. important::
221
+
222
+ Call this property once and assign it to a temporary variable as
223
+ shown in the examples above. Then use the ``rpc`` variable to
224
+ access the different RPC methods!
225
+
226
+ Starting with tcms-api v12.9.1 this property is automatically refreshed
227
+ every 4 minutes to avoid SSL connection timeout errors!
195
228
  """
196
- return _ConnectionProxy()
229
+ return _ConnectionProxy(self.config)
@@ -0,0 +1 @@
1
+ __version__ = "13.2"
@@ -177,7 +177,9 @@ class TCMSKerbXmlrpc(TCMSXmlrpc):
177
177
  # note: by default will follow redirects
178
178
  with requests.sessions.Session() as session:
179
179
  response = session.get(url, headers=headers)
180
- assert response.status_code == HTTPStatus.OK
180
+ if response.status_code != HTTPStatus.OK:
181
+ raise RuntimeError(f"Unexpected HTTP response {response}")
182
+
181
183
  self.transport._cookies.append( # pylint: disable=protected-access
182
184
  self.session_cookie_name
183
185
  + "="
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tcms-api
3
- Version: 12.9.1
3
+ Version: 13.2
4
4
  Summary: Python API for Kiwi
5
5
  Home-page: https://github.com/kiwitcms/tcms-api
6
6
  Maintainer: Kiwi TCMS
@@ -69,6 +69,18 @@ https://tcms-api.readthedocs.io/en/latest/modules/tcms_api.html
69
69
  CHANGELOG
70
70
  ---------
71
71
 
72
+ v13.2 (27 Apr 2024)
73
+ ~~~~~~~~~~~~~~~~~~~
74
+
75
+ - Respect configuration passed as arguments to the ``TCMS()`` class, for example::
76
+
77
+ TCMS("https://kiwitcms.example.com/xml-rpc/", "api-bot", "keep-me-secret")
78
+
79
+ - Adjust usage examples and documentation for ``.exec()``. Closes
80
+ `Issue #77 <https://github.com/kiwitcms/tcms-api/issues/77>`_
81
+ - Internal changes related to testing and building this package
82
+
83
+
72
84
  v12.9.1 (13 Jan 2024)
73
85
  ~~~~~~~~~~~~~~~~~~~~~
74
86
 
@@ -1 +0,0 @@
1
- __version__ = "12.9.1"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes