testit-adapter-nose 3.3.1__tar.gz → 3.4.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: testit-adapter-nose
3
- Version: 3.3.1
3
+ Version: 3.4.0
4
4
  Summary: Nose adapter for Test IT
5
5
  Home-page: https://github.com/testit-tms/adapters-python/
6
6
  Author: Integration team
@@ -17,7 +17,7 @@ Classifier: Programming Language :: Python :: 3.12
17
17
  Description-Content-Type: text/markdown
18
18
  Requires-Dist: attrs
19
19
  Requires-Dist: nose2
20
- Requires-Dist: testit-python-commons==3.3.1
20
+ Requires-Dist: testit-python-commons==3.4.0
21
21
 
22
22
  # Test IT TMS adapter for Nose
23
23
 
@@ -52,6 +52,7 @@ pip install testit-adapter-nose
52
52
  | It enables/disables certificate validation (**It's optional**). Default value - true | certValidation | TMS_CERT_VALIDATION |
53
53
  | Mode of automatic creation test cases (**It's optional**). Default value - false. The adapter supports following modes:<br/>true - in this mode, the adapter will create a test case linked to the created autotest (not to the updated autotest)<br/>false - in this mode, the adapter will not create a test case | automaticCreationTestCases | TMS_AUTOMATIC_CREATION_TEST_CASES |
54
54
  | Mode of automatic updation links to test cases (**It's optional**). Default value - false. The adapter supports following modes:<br/>true - in this mode, the adapter will update links to test cases<br/>false - in this mode, the adapter will not update link to test cases | automaticUpdationLinksToTestCases | TMS_AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES |
55
+ | Mode of import type selection when launching autotests (**It's optional**). Default value - true. The adapter supports following modes:<br/>true - in this mode, the adapter will create/update each autotest in real time<br/>false - in this mode, the adapter will create/update multiple autotests | importRealtime | TMS_IMPORT_REALTIME |
55
56
  | Url of proxy server (**It's optional**) | tmsProxy | TMS_PROXY |
56
57
  | Name of the configuration file If it is not provided, it is used default file name (**It's optional**) | - | TMS_CONFIG_FILE |
57
58
 
@@ -70,6 +71,7 @@ adapterMode = ADAPTER_MODE
70
71
  certValidation = CERT_VALIDATION
71
72
  automaticCreationTestCases = AUTOMATIC_CREATION_TEST_CASES
72
73
  automaticUpdationLinksToTestCases = AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES
74
+ importRealtime = IMPORT_REALTIME
73
75
 
74
76
  # This section are optional. It enables debug mode.
75
77
  [debug]
@@ -87,6 +89,21 @@ $ nose2 --testit
87
89
  If you want to enable debug mode then
88
90
  see [How to enable debug logging?](https://github.com/testit-tms/adapters-python/tree/main/testit-python-commons)
89
91
 
92
+ #### Run with filter
93
+ To create filter by autotests you can use the Test IT CLI (use adapterMode 1 for run with filter):
94
+
95
+ ```
96
+ $ export TMS_TOKEN=<YOUR_TOKEN>
97
+ $ testit autotests_filter
98
+ --url https://tms.testit.software \
99
+ --configuration-id 5236eb3f-7c05-46f9-a609-dc0278896464 \
100
+ --testrun-id 6d4ac4b7-dd67-4805-b879-18da0b89d4a8 \
101
+ --framework nose \
102
+ --output tmp/filter.txt
103
+
104
+ $ nose2 $(cat tmp/filter.txt) --testit
105
+ ```
106
+
90
107
  ### Decorators
91
108
 
92
109
  Decorators can be used to specify information about autotest.
@@ -1,24 +1,3 @@
1
- Metadata-Version: 2.1
2
- Name: testit-adapter-nose
3
- Version: 3.3.1
4
- Summary: Nose adapter for Test IT
5
- Home-page: https://github.com/testit-tms/adapters-python/
6
- Author: Integration team
7
- Author-email: integrations@testit.software
8
- License: Apache-2.0
9
- Classifier: Programming Language :: Python :: 3
10
- Classifier: Programming Language :: Python :: 3.6
11
- Classifier: Programming Language :: Python :: 3.7
12
- Classifier: Programming Language :: Python :: 3.8
13
- Classifier: Programming Language :: Python :: 3.9
14
- Classifier: Programming Language :: Python :: 3.10
15
- Classifier: Programming Language :: Python :: 3.11
16
- Classifier: Programming Language :: Python :: 3.12
17
- Description-Content-Type: text/markdown
18
- Requires-Dist: attrs
19
- Requires-Dist: nose2
20
- Requires-Dist: testit-python-commons==3.3.1
21
-
22
1
  # Test IT TMS adapter for Nose
23
2
 
24
3
  ![Test IT](https://raw.githubusercontent.com/testit-tms/adapters-python/master/images/banner.png)
@@ -52,6 +31,7 @@ pip install testit-adapter-nose
52
31
  | It enables/disables certificate validation (**It's optional**). Default value - true | certValidation | TMS_CERT_VALIDATION |
53
32
  | Mode of automatic creation test cases (**It's optional**). Default value - false. The adapter supports following modes:<br/>true - in this mode, the adapter will create a test case linked to the created autotest (not to the updated autotest)<br/>false - in this mode, the adapter will not create a test case | automaticCreationTestCases | TMS_AUTOMATIC_CREATION_TEST_CASES |
54
33
  | Mode of automatic updation links to test cases (**It's optional**). Default value - false. The adapter supports following modes:<br/>true - in this mode, the adapter will update links to test cases<br/>false - in this mode, the adapter will not update link to test cases | automaticUpdationLinksToTestCases | TMS_AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES |
34
+ | Mode of import type selection when launching autotests (**It's optional**). Default value - true. The adapter supports following modes:<br/>true - in this mode, the adapter will create/update each autotest in real time<br/>false - in this mode, the adapter will create/update multiple autotests | importRealtime | TMS_IMPORT_REALTIME |
55
35
  | Url of proxy server (**It's optional**) | tmsProxy | TMS_PROXY |
56
36
  | Name of the configuration file If it is not provided, it is used default file name (**It's optional**) | - | TMS_CONFIG_FILE |
57
37
 
@@ -70,6 +50,7 @@ adapterMode = ADAPTER_MODE
70
50
  certValidation = CERT_VALIDATION
71
51
  automaticCreationTestCases = AUTOMATIC_CREATION_TEST_CASES
72
52
  automaticUpdationLinksToTestCases = AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES
53
+ importRealtime = IMPORT_REALTIME
73
54
 
74
55
  # This section are optional. It enables debug mode.
75
56
  [debug]
@@ -87,6 +68,21 @@ $ nose2 --testit
87
68
  If you want to enable debug mode then
88
69
  see [How to enable debug logging?](https://github.com/testit-tms/adapters-python/tree/main/testit-python-commons)
89
70
 
71
+ #### Run with filter
72
+ To create filter by autotests you can use the Test IT CLI (use adapterMode 1 for run with filter):
73
+
74
+ ```
75
+ $ export TMS_TOKEN=<YOUR_TOKEN>
76
+ $ testit autotests_filter
77
+ --url https://tms.testit.software \
78
+ --configuration-id 5236eb3f-7c05-46f9-a609-dc0278896464 \
79
+ --testrun-id 6d4ac4b7-dd67-4805-b879-18da0b89d4a8 \
80
+ --framework nose \
81
+ --output tmp/filter.txt
82
+
83
+ $ nose2 $(cat tmp/filter.txt) --testit
84
+ ```
85
+
90
86
  ### Decorators
91
87
 
92
88
  Decorators can be used to specify information about autotest.
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='testit-adapter-nose',
5
- version='3.3.1',
5
+ version='3.4.0',
6
6
  description='Nose adapter for Test IT',
7
7
  long_description=open('README.md', "r").read(),
8
8
  long_description_content_type="text/markdown",
@@ -23,7 +23,7 @@ setup(
23
23
  py_modules=['testit_adapter_nose'],
24
24
  packages=find_packages(where='src'),
25
25
  package_dir={'': 'src'},
26
- install_requires=['attrs', 'nose2', 'testit-python-commons==3.3.1'],
26
+ install_requires=['attrs', 'nose2', 'testit-python-commons==3.4.0'],
27
27
  entry_points={
28
28
  'nose.plugins.0.10': [
29
29
  'testit_adapter_nose = testit_adapter_nose.plugin:TmsPlugin',
@@ -12,20 +12,24 @@ from .utils import (
12
12
  class AdapterListener(object):
13
13
  __executable_test = None
14
14
 
15
- def __init__(self, adapter_manager: AdapterManager, step_manager: StepManager):
15
+ def __init__(self, adapter_manager: AdapterManager, step_manager: StepManager, top_level_directory: str):
16
16
  self.__adapter_manager = adapter_manager
17
17
  self.__step_manager = step_manager
18
+ self.__top_level_directory = top_level_directory
18
19
 
19
20
  def start_launch(self):
20
21
  test_run_id = self.__adapter_manager.get_test_run_id()
21
22
 
22
23
  self.__adapter_manager.set_test_run_id(test_run_id)
23
24
 
25
+ def stop_launch(self):
26
+ self.__adapter_manager.write_tests()
27
+
24
28
  def get_tests_for_launch(self):
25
29
  return self.__adapter_manager.get_autotests_for_launch()
26
30
 
27
31
  def start_test(self, test):
28
- self.__executable_test = form_test(test)
32
+ self.__executable_test = form_test(test, self.__top_level_directory)
29
33
 
30
34
  def set_outcome(self, event):
31
35
  outcome, message, trace = get_outcome(event)
@@ -10,20 +10,29 @@ class TmsPlugin(Plugin):
10
10
  commandLineSwitch = (None, 'testit', 'TMS adapter for Nose')
11
11
  __listener = None
12
12
  __tests_for_launch = None
13
+ __top_level_directory = None
13
14
 
14
15
  def __init__(self, *args, **kwargs):
15
16
  super(TmsPlugin, self).__init__(*args, **kwargs)
16
17
 
18
+ def handleDir(self, event):
19
+ if not self.__top_level_directory:
20
+ self.__top_level_directory = event.topLevelDirectory
21
+
17
22
  def startTestRun(self, event):
18
23
  self.__listener = AdapterListener(
19
24
  TmsPluginManager.get_adapter_manager(),
20
- TmsPluginManager.get_step_manager())
25
+ TmsPluginManager.get_step_manager(),
26
+ self.__top_level_directory)
21
27
 
22
28
  TmsPluginManager.get_plugin_manager().register(self.__listener)
23
29
 
24
30
  self.__listener.start_launch()
25
31
  self.__tests_for_launch = self.__listener.get_tests_for_launch()
26
32
 
33
+ def afterTestRun(self, event):
34
+ self.__listener.stop_launch()
35
+
27
36
  def startTest(self, event):
28
37
  self.__listener.start_test(event.test)
29
38
 
@@ -1,6 +1,8 @@
1
1
  import hashlib
2
2
  import logging
3
3
  import re
4
+ import os
5
+ import typing
4
6
  from traceback import format_exception_only
5
7
  from nose2 import (
6
8
  util,
@@ -62,7 +64,7 @@ def get_outcome(event):
62
64
  return outcome, message, trace
63
65
 
64
66
 
65
- def form_test(item):
67
+ def form_test(item, top_level_directory):
66
68
  data = {}
67
69
 
68
70
  if hasattr(item, "_testFunc"):
@@ -90,7 +92,8 @@ def form_test(item):
90
92
  'links': __get_links_from(item),
91
93
  'labels': __get_labels_from(item),
92
94
  'workItemsID': __get_work_item_ids_from(item),
93
- 'message': None
95
+ 'message': None,
96
+ 'externalKey': __get_fullname(item, top_level_directory)
94
97
  }
95
98
 
96
99
  elif hasattr(item, "_testMethodName"):
@@ -258,6 +261,37 @@ def __get_work_item_ids_from(item):
258
261
  return map(str, result) if isinstance(result, __ARRAY_TYPES) else [str(result)]
259
262
 
260
263
 
264
+ def __get_fullname(item, top_level_directory: str):
265
+ test_function = item._testFunc
266
+ module_file_name = __get_module_file_name_by_test_function(test_function)
267
+
268
+ if not module_file_name:
269
+ return __join_nose_test_node([test_function.__module__, test_function.__qualname__])
270
+
271
+ absolute_module_path = __get_absolute_module_path_by_file_name(module_file_name)
272
+ module_node = __convert_absolute_module_path_to_nose_module_node(absolute_module_path, top_level_directory)
273
+
274
+ return __join_nose_test_node([module_node, test_function.__module__, test_function.__qualname__])
275
+
276
+
277
+ def __get_module_file_name_by_test_function(test_function):
278
+ return __import__(test_function.__module__).__file__
279
+
280
+
281
+ def __get_absolute_module_path_by_file_name(module_file_name: str):
282
+ return os.path.dirname(module_file_name)
283
+
284
+
285
+ def __convert_absolute_module_path_to_nose_module_node(absolute_module_path: str, top_level_directory: str):
286
+ directories_in_project = absolute_module_path.replace(top_level_directory + os.sep, '')
287
+
288
+ return directories_in_project.replace(os.sep, '.')
289
+
290
+
291
+ def __join_nose_test_node(test_node_parts: typing.List[str]):
292
+ return ".".join(test_node_parts)
293
+
294
+
261
295
  def fullname(event):
262
296
  if hasattr(event.test, "_testFunc"):
263
297
  test_module = event.test._testFunc.__module__
@@ -379,4 +413,5 @@ def convert_executable_test_to_test_result_model(executable_test: dict) -> TestR
379
413
  .set_result_links(executable_test['resultLinks'])\
380
414
  .set_labels(executable_test['labels'])\
381
415
  .set_work_item_ids(executable_test['workItemsID'])\
382
- .set_message(executable_test['message'])
416
+ .set_message(executable_test['message'])\
417
+ .set_external_key(executable_test['externalKey'])
@@ -1,3 +1,24 @@
1
+ Metadata-Version: 2.1
2
+ Name: testit-adapter-nose
3
+ Version: 3.4.0
4
+ Summary: Nose adapter for Test IT
5
+ Home-page: https://github.com/testit-tms/adapters-python/
6
+ Author: Integration team
7
+ Author-email: integrations@testit.software
8
+ License: Apache-2.0
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.6
11
+ Classifier: Programming Language :: Python :: 3.7
12
+ Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: attrs
19
+ Requires-Dist: nose2
20
+ Requires-Dist: testit-python-commons==3.4.0
21
+
1
22
  # Test IT TMS adapter for Nose
2
23
 
3
24
  ![Test IT](https://raw.githubusercontent.com/testit-tms/adapters-python/master/images/banner.png)
@@ -31,6 +52,7 @@ pip install testit-adapter-nose
31
52
  | It enables/disables certificate validation (**It's optional**). Default value - true | certValidation | TMS_CERT_VALIDATION |
32
53
  | Mode of automatic creation test cases (**It's optional**). Default value - false. The adapter supports following modes:<br/>true - in this mode, the adapter will create a test case linked to the created autotest (not to the updated autotest)<br/>false - in this mode, the adapter will not create a test case | automaticCreationTestCases | TMS_AUTOMATIC_CREATION_TEST_CASES |
33
54
  | Mode of automatic updation links to test cases (**It's optional**). Default value - false. The adapter supports following modes:<br/>true - in this mode, the adapter will update links to test cases<br/>false - in this mode, the adapter will not update link to test cases | automaticUpdationLinksToTestCases | TMS_AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES |
55
+ | Mode of import type selection when launching autotests (**It's optional**). Default value - true. The adapter supports following modes:<br/>true - in this mode, the adapter will create/update each autotest in real time<br/>false - in this mode, the adapter will create/update multiple autotests | importRealtime | TMS_IMPORT_REALTIME |
34
56
  | Url of proxy server (**It's optional**) | tmsProxy | TMS_PROXY |
35
57
  | Name of the configuration file If it is not provided, it is used default file name (**It's optional**) | - | TMS_CONFIG_FILE |
36
58
 
@@ -49,6 +71,7 @@ adapterMode = ADAPTER_MODE
49
71
  certValidation = CERT_VALIDATION
50
72
  automaticCreationTestCases = AUTOMATIC_CREATION_TEST_CASES
51
73
  automaticUpdationLinksToTestCases = AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES
74
+ importRealtime = IMPORT_REALTIME
52
75
 
53
76
  # This section are optional. It enables debug mode.
54
77
  [debug]
@@ -66,6 +89,21 @@ $ nose2 --testit
66
89
  If you want to enable debug mode then
67
90
  see [How to enable debug logging?](https://github.com/testit-tms/adapters-python/tree/main/testit-python-commons)
68
91
 
92
+ #### Run with filter
93
+ To create filter by autotests you can use the Test IT CLI (use adapterMode 1 for run with filter):
94
+
95
+ ```
96
+ $ export TMS_TOKEN=<YOUR_TOKEN>
97
+ $ testit autotests_filter
98
+ --url https://tms.testit.software \
99
+ --configuration-id 5236eb3f-7c05-46f9-a609-dc0278896464 \
100
+ --testrun-id 6d4ac4b7-dd67-4805-b879-18da0b89d4a8 \
101
+ --framework nose \
102
+ --output tmp/filter.txt
103
+
104
+ $ nose2 $(cat tmp/filter.txt) --testit
105
+ ```
106
+
69
107
  ### Decorators
70
108
 
71
109
  Decorators can be used to specify information about autotest.
@@ -0,0 +1,3 @@
1
+ attrs
2
+ nose2
3
+ testit-python-commons==3.4.0
@@ -1,3 +0,0 @@
1
- attrs
2
- nose2
3
- testit-python-commons==3.3.1