pytestomatio 2.8.2.dev8__tar.gz → 2.8.2.dev10__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 (40) hide show
  1. {pytestomatio-2.8.2.dev8/pytestomatio.egg-info → pytestomatio-2.8.2.dev10}/PKG-INFO +4 -2
  2. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/README.md +3 -1
  3. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/pyproject.toml +1 -1
  4. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/pytestomatio/connect/s3_connector.py +23 -14
  5. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/pytestomatio/main.py +8 -9
  6. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/pytestomatio/utils/helper.py +9 -5
  7. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10/pytestomatio.egg-info}/PKG-INFO +4 -2
  8. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/LICENSE +0 -0
  9. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/pytestomatio/__init__.py +0 -0
  10. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/pytestomatio/connect/__init__.py +0 -0
  11. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/pytestomatio/connect/connector.py +0 -0
  12. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/pytestomatio/decor/__init__.py +0 -0
  13. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/pytestomatio/decor/decorator_updater.py +0 -0
  14. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/pytestomatio/decor/default.py +0 -0
  15. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/pytestomatio/decor/pep8.py +0 -0
  16. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/pytestomatio/testing/__init__.py +0 -0
  17. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/pytestomatio/testing/code_collector.py +0 -0
  18. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/pytestomatio/testing/testItem.py +0 -0
  19. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/pytestomatio/testomatio/__init__.py +0 -0
  20. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/pytestomatio/testomatio/testRunConfig.py +0 -0
  21. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/pytestomatio/testomatio/testomat_item.py +0 -0
  22. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/pytestomatio/testomatio/testomatio.py +0 -0
  23. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/pytestomatio/utils/__init__.py +0 -0
  24. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/pytestomatio/utils/parser_setup.py +0 -0
  25. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/pytestomatio/utils/validations.py +0 -0
  26. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/pytestomatio.egg-info/SOURCES.txt +0 -0
  27. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/pytestomatio.egg-info/dependency_links.txt +0 -0
  28. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/pytestomatio.egg-info/entry_points.txt +0 -0
  29. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/pytestomatio.egg-info/requires.txt +0 -0
  30. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/pytestomatio.egg-info/top_level.txt +0 -0
  31. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/setup.cfg +0 -0
  32. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/tests/sub/__init__.py +0 -0
  33. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/tests/sub/sub_mob/__init__.py +0 -0
  34. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/tests/sub/sub_mob/sub_sub_class_test.py +0 -0
  35. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/tests/sub/sub_mob/sub_sub_test.py +0 -0
  36. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/tests/sub/test_class_sub.py +0 -0
  37. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/tests/sub/test_sub.py +0 -0
  38. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/tests/test_class_root.py +0 -0
  39. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/tests/test_decorators.py +0 -0
  40. {pytestomatio-2.8.2.dev8 → pytestomatio-2.8.2.dev10}/tests/test_root.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pytestomatio
3
- Version: 2.8.2.dev8
3
+ Version: 2.8.2.dev10
4
4
  Summary: Pytest plugin to sync test with testomat.io
5
5
  Author: Oleksii Ostapov, TikoQA
6
6
  Project-URL: Testomat.io, https://testomat.io/
@@ -114,7 +114,7 @@ https://docs.testomat.io/usage/test-artifacts/
114
114
  Analyser needs to be aware of the cloud storage credentials.
115
115
  There are two options:
116
116
  1. Enable **Share credentials with testomat.io Reporter** option in testomat.io Settings -> Artifacts.
117
- 2. Use environment variables `ACCESS_KEY_ID, SECRET_ACCESS_KEY, ENDPOINT, BUCKET`
117
+ 2. Use environment variables `ACCESS_KEY_ID, SECRET_ACCESS_KEY, ENDPOINT, BUCKET, BUCKET_PATH`
118
118
 
119
119
  You would need to decide when you want to upload your test artifacts to cloud storage
120
120
 
@@ -219,6 +219,8 @@ def test_example():
219
219
  - test run labels, tags
220
220
 
221
221
  ## TODO
222
+ - retry test run update with less attributes, we get 500 from api
223
+ - handler non configured s3 bucket error
222
224
  - Fix test duration
223
225
 
224
226
  ## Contribution
@@ -92,7 +92,7 @@ https://docs.testomat.io/usage/test-artifacts/
92
92
  Analyser needs to be aware of the cloud storage credentials.
93
93
  There are two options:
94
94
  1. Enable **Share credentials with testomat.io Reporter** option in testomat.io Settings -> Artifacts.
95
- 2. Use environment variables `ACCESS_KEY_ID, SECRET_ACCESS_KEY, ENDPOINT, BUCKET`
95
+ 2. Use environment variables `ACCESS_KEY_ID, SECRET_ACCESS_KEY, ENDPOINT, BUCKET, BUCKET_PATH`
96
96
 
97
97
  You would need to decide when you want to upload your test artifacts to cloud storage
98
98
 
@@ -197,6 +197,8 @@ def test_example():
197
197
  - test run labels, tags
198
198
 
199
199
  ## TODO
200
+ - retry test run update with less attributes, we get 500 from api
201
+ - handler non configured s3 bucket error
200
202
  - Fix test duration
201
203
 
202
204
  ## Contribution
@@ -13,7 +13,7 @@ version_provider = "pep621"
13
13
  update_changelog_on_bump = false
14
14
  [project]
15
15
  name = "pytestomatio"
16
- version = "2.8.2.dev8"
16
+ version = "2.8.2.dev10"
17
17
 
18
18
  dependencies = [
19
19
  "requests>=2.29.0",
@@ -1,3 +1,4 @@
1
+ from typing import Optional
1
2
  import boto3
2
3
  import logging
3
4
  from io import BytesIO
@@ -6,7 +7,7 @@ log = logging.getLogger(__name__)
6
7
  log.setLevel('INFO')
7
8
 
8
9
 
9
- def parse_endpoint(endpoint: str or None) -> str or None:
10
+ def parse_endpoint(endpoint: str = None) -> Optional[str]:
10
11
  if endpoint is None:
11
12
  return
12
13
  if endpoint.startswith('https://'):
@@ -15,15 +16,20 @@ def parse_endpoint(endpoint: str or None) -> str or None:
15
16
  return endpoint[7:]
16
17
  return endpoint
17
18
 
18
-
19
19
  class S3Connector:
20
- def __init__(self, aws_access_key_id: str or None = None,
21
- aws_secret_access_key: str or None = None,
22
- endpoint: str or None = None,
23
- bucket_name: str or None = None):
20
+ def __init__(self,
21
+ aws_region_name: Optional[str],
22
+ aws_access_key_id: Optional[str],
23
+ aws_secret_access_key: Optional[str],
24
+ endpoint: Optional[str],
25
+ bucket_name: Optional[str],
26
+ bucker_prefix: Optional[str]
27
+ ):
24
28
 
29
+ self.aws_region_name = aws_region_name
25
30
  self.endpoint = parse_endpoint(endpoint)
26
31
  self.bucket_name = bucket_name
32
+ self.bucker_prefix = bucker_prefix
27
33
  self.client = None
28
34
  self._is_logged_in = False
29
35
  self.aws_access_key_id = aws_access_key_id
@@ -35,35 +41,38 @@ class S3Connector:
35
41
  's3',
36
42
  endpoint_url=f'https://{self.endpoint}',
37
43
  aws_access_key_id=self.aws_access_key_id,
38
- aws_secret_access_key=self.aws_secret_access_key)
44
+ aws_secret_access_key=self.aws_secret_access_key,
45
+ region_name=self.aws_region_name
46
+ )
47
+
39
48
  self._is_logged_in = True
40
49
  log.info('s3 session created')
41
50
 
42
- def upload_file(self, file_path: str, key: str = None, bucket_name: str = None) -> str or None:
51
+ def upload_file(self, file_path: str, key: str = None, bucket_name: str = None) -> Optional[str]:
43
52
  if not self._is_logged_in:
44
53
  log.warning('s3 session is not created, creating new one')
45
54
  return
46
55
  if not key:
47
56
  key = file_path
57
+ key = f"{self.bucker_prefix}/{key}"
48
58
  if not bucket_name:
49
59
  bucket_name = self.bucket_name
50
- if bucket_name is None:
51
- raise Exception('bucket name is not defined')
60
+
52
61
  log.info(f'uploading artifact {file_path} to s3://{bucket_name}/{key}')
53
62
  self.client.upload_file(file_path, bucket_name, key)
54
63
  log.info(f'artifact {file_path} uploaded to s3://{bucket_name}/{key}')
55
64
  return f'https://{bucket_name}.{self.endpoint}/{key}'
56
65
 
57
- def upload_file_object(self, file_bytes: bytes, key: str, bucket_name: str = None) -> str or None:
66
+ def upload_file_object(self, file_bytes: bytes, key: str, bucket_name: str = None) -> Optional[str]:
58
67
  if not self._is_logged_in:
59
68
  log.warning('s3 session is not created, creating new one')
60
69
  return
61
70
  file = BytesIO(file_bytes)
62
71
  if not bucket_name:
63
72
  bucket_name = self.bucket_name
64
- if bucket_name is None:
65
- raise Exception('bucket name is not defined')
73
+ key = f"{self.bucker_prefix}/{key}"
74
+
66
75
  log.info(f'uploading artifact {key} to s3://{bucket_name}/{key}')
67
76
  self.client.upload_fileobj(file, bucket_name, key)
68
77
  log.info(f'artifact {key} uploaded to s3://{bucket_name}/{key}')
69
- return f'https://{bucket_name}.{self.endpoint}/{key}'
78
+ return f'https://{bucket_name}.{self.endpoint}/{key}'
@@ -114,15 +114,14 @@ def pytest_collection_modifyitems(session: Session, config: Config, items: list[
114
114
  log.error('Test run failed to create. Reporting skipped')
115
115
  return
116
116
 
117
- artifact = run_details.get('artifacts')
118
- if artifact:
119
- s3_details = helper.read_env_s3_keys(artifact)
120
-
121
- if all(s3_details):
122
- pytest.testomatio.s3_connector = S3Connector(*s3_details)
123
- pytest.testomatio.s3_connector.login()
124
- else:
125
- pytest.testomatio.s3_connector = S3Connector()
117
+ s3_details = helper.read_env_s3_keys(run_details)
118
+
119
+ if all(s3_details):
120
+ pytest.testomatio.s3_connector = S3Connector(*s3_details)
121
+ pytest.testomatio.s3_connector.login()
122
+ else:
123
+ pytest.testomatio.s3_connector = S3Connector()
124
+
126
125
  case 'debug':
127
126
  with open(metadata_file, 'w') as file:
128
127
  data = json.dumps([i.to_dict() for i in meta], indent=4)
@@ -84,12 +84,16 @@ def add_and_enrich_tests(meta: list[TestItem], test_files: set,
84
84
  update_tests(test_file, mapping, test_names, decorator_name)
85
85
 
86
86
 
87
- def read_env_s3_keys(artifact: dict) -> tuple:
87
+ def read_env_s3_keys(testRunConfig: dict) -> tuple:
88
+ artifacts = testRunConfig.get('artifacts')
89
+ bucket_path = (os.environ.get('BUCKET_PATH') or os.environ.get('S3_BUCKET_PATH'))
88
90
  return (
89
- os.environ.get('ACCESS_KEY_ID') or artifact.get('ACCESS_KEY_ID'),
90
- os.environ.get('SECRET_ACCESS_KEY') or artifact.get('SECRET_ACCESS_KEY'),
91
- os.environ.get('ENDPOINT') or artifact.get('ENDPOINT'),
92
- os.environ.get('BUCKET') or artifact.get('BUCKET')
91
+ os.environ.get('REGION') or os.environ.get('S3_REGION') or artifacts.get('REGION'),
92
+ os.environ.get('ACCESS_KEY_ID') or os.environ.get('S3_ACCESS_KEY_ID') or artifacts.get('ACCESS_KEY_ID'),
93
+ os.environ.get('SECRET_ACCESS_KEY') or os.environ.get('S3_SECRET_ACCESS_KEY') or artifacts.get('SECRET_ACCESS_KEY'),
94
+ os.environ.get('ENDPOINT') or os.environ.get('S3_ENDPOINT') or artifacts.get('ENDPOINT'),
95
+ os.environ.get('BUCKET') or os.environ.get('S3_BUCKET') or artifacts.get('BUCKET'),
96
+ bucket_path + "/" + testRunConfig.get("uid") if bucket_path else testRunConfig.get("uid")
93
97
  )
94
98
 
95
99
  def safe_string_list(param: str):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pytestomatio
3
- Version: 2.8.2.dev8
3
+ Version: 2.8.2.dev10
4
4
  Summary: Pytest plugin to sync test with testomat.io
5
5
  Author: Oleksii Ostapov, TikoQA
6
6
  Project-URL: Testomat.io, https://testomat.io/
@@ -114,7 +114,7 @@ https://docs.testomat.io/usage/test-artifacts/
114
114
  Analyser needs to be aware of the cloud storage credentials.
115
115
  There are two options:
116
116
  1. Enable **Share credentials with testomat.io Reporter** option in testomat.io Settings -> Artifacts.
117
- 2. Use environment variables `ACCESS_KEY_ID, SECRET_ACCESS_KEY, ENDPOINT, BUCKET`
117
+ 2. Use environment variables `ACCESS_KEY_ID, SECRET_ACCESS_KEY, ENDPOINT, BUCKET, BUCKET_PATH`
118
118
 
119
119
  You would need to decide when you want to upload your test artifacts to cloud storage
120
120
 
@@ -219,6 +219,8 @@ def test_example():
219
219
  - test run labels, tags
220
220
 
221
221
  ## TODO
222
+ - retry test run update with less attributes, we get 500 from api
223
+ - handler non configured s3 bucket error
222
224
  - Fix test duration
223
225
 
224
226
  ## Contribution