atk-common 1.17.0__tar.gz → 1.19.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 (33) hide show
  1. {atk_common-1.17.0 → atk_common-1.19.0}/PKG-INFO +14 -2
  2. {atk_common-1.17.0 → atk_common-1.19.0}/setup.py +1 -1
  3. {atk_common-1.17.0 → atk_common-1.19.0}/src/atk_common/error_utils.py +9 -9
  4. {atk_common-1.17.0 → atk_common-1.19.0}/src/atk_common.egg-info/PKG-INFO +14 -2
  5. {atk_common-1.17.0 → atk_common-1.19.0}/tests/test_docker_utils.py +3 -1
  6. atk_common-1.19.0/tests/test_error_utils.py +28 -0
  7. {atk_common-1.17.0 → atk_common-1.19.0}/tests/test_http_utils.py +3 -1
  8. {atk_common-1.17.0 → atk_common-1.19.0}/tests/test_log_utils.py +3 -1
  9. atk_common-1.17.0/tests/test_error_utils.py +0 -21
  10. {atk_common-1.17.0 → atk_common-1.19.0}/README.md +0 -0
  11. {atk_common-1.17.0 → atk_common-1.19.0}/license.txt +0 -0
  12. {atk_common-1.17.0 → atk_common-1.19.0}/pyproject.toml +0 -0
  13. {atk_common-1.17.0 → atk_common-1.19.0}/setup.cfg +0 -0
  14. {atk_common-1.17.0 → atk_common-1.19.0}/src/atk_common/__init__.py +0 -0
  15. {atk_common-1.17.0 → atk_common-1.19.0}/src/atk_common/datetime_utils.py +0 -0
  16. {atk_common-1.17.0 → atk_common-1.19.0}/src/atk_common/db_utils.py +0 -0
  17. {atk_common-1.17.0 → atk_common-1.19.0}/src/atk_common/docker_utils.py +0 -0
  18. {atk_common-1.17.0 → atk_common-1.19.0}/src/atk_common/enums/__init__.py +0 -0
  19. {atk_common-1.17.0 → atk_common-1.19.0}/src/atk_common/enums/api_error_type_enum.py +0 -0
  20. {atk_common-1.17.0 → atk_common-1.19.0}/src/atk_common/enums/command_status_enum.py +0 -0
  21. {atk_common-1.17.0 → atk_common-1.19.0}/src/atk_common/enums/response_status_enum.py +0 -0
  22. {atk_common-1.17.0 → atk_common-1.19.0}/src/atk_common/enums/speed_control_status_enum.py +0 -0
  23. {atk_common-1.17.0 → atk_common-1.19.0}/src/atk_common/env_utils.py +0 -0
  24. {atk_common-1.17.0 → atk_common-1.19.0}/src/atk_common/http_utils.py +0 -0
  25. {atk_common-1.17.0 → atk_common-1.19.0}/src/atk_common/log_utils.py +0 -0
  26. {atk_common-1.17.0 → atk_common-1.19.0}/src/atk_common/mq_utils.py +0 -0
  27. {atk_common-1.17.0 → atk_common-1.19.0}/src/atk_common/rabbitmq_consumer.py +0 -0
  28. {atk_common-1.17.0 → atk_common-1.19.0}/src/atk_common/response_utils.py +0 -0
  29. {atk_common-1.17.0 → atk_common-1.19.0}/src/atk_common.egg-info/SOURCES.txt +0 -0
  30. {atk_common-1.17.0 → atk_common-1.19.0}/src/atk_common.egg-info/dependency_links.txt +0 -0
  31. {atk_common-1.17.0 → atk_common-1.19.0}/src/atk_common.egg-info/requires.txt +0 -0
  32. {atk_common-1.17.0 → atk_common-1.19.0}/src/atk_common.egg-info/top_level.txt +0 -0
  33. {atk_common-1.17.0 → atk_common-1.19.0}/src/shared_python_atk_enforcement/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: atk_common
3
- Version: 1.17.0
3
+ Version: 1.19.0
4
4
  Summary: ATK common methods
5
5
  Home-page: https://github.com/pypa/atk_common
6
6
  Author: Roger
@@ -25,5 +25,17 @@ Description-Content-Type: text/markdown
25
25
  License-File: license.txt
26
26
  Requires-Dist: kombu>=5.4.2
27
27
  Requires-Dist: requests>=2.32.3
28
+ Dynamic: author
29
+ Dynamic: author-email
30
+ Dynamic: classifier
31
+ Dynamic: description
32
+ Dynamic: description-content-type
33
+ Dynamic: home-page
34
+ Dynamic: keywords
35
+ Dynamic: license-file
36
+ Dynamic: project-url
37
+ Dynamic: requires-dist
38
+ Dynamic: requires-python
39
+ Dynamic: summary
28
40
 
29
41
  This package contains atk enforcement common entities and components
@@ -36,7 +36,7 @@ setup(
36
36
  # For a discussion on single-sourcing the version across setup.py and the
37
37
  # project code, see
38
38
  # https://packaging.python.org/guides/single-sourcing-package-version/
39
- version="1.17.0", # Required
39
+ version="1.19.0", # Required
40
40
  # This is a one-line description or tagline of what your project does. This
41
41
  # corresponds to the "Summary" metadata field:
42
42
  # https://packaging.python.org/specifications/core-metadata/#summary
@@ -1,5 +1,7 @@
1
1
  from http import HTTPStatus
2
+ from flask import Response
2
3
  from datetime import datetime
4
+ from enum import Enum
3
5
  import json
4
6
  from atk_common.datetime_utils import get_utc_date_time
5
7
  from atk_common.enums.api_error_type_enum import ApiErrorType
@@ -25,23 +27,21 @@ def create_error_log(data):
25
27
  err_str += ', containerName: <none>'
26
28
  add_log_item(err_str)
27
29
 
28
- def get_error_entity(app, error, method, error_type, status_code, container_info):
30
+ def get_error_entity(error, method, error_type, status_code, container_info):
29
31
  data = {}
30
32
  data['statusCode'] = status_code
31
33
  data['exceptionType'] = str(type(error))
32
- data['errorType'] = error_type
34
+ data['errorType'] = error_type.value if isinstance(error_type, Enum) else error_type
33
35
  data['message'] = get_message(error)
34
36
  data['method'] = method
35
37
  data['timestamp'] = get_utc_date_time()
36
38
  data['containerInfo'] = container_info
37
39
  create_error_log(data)
38
- if app is not None:
39
- return app.response_class(
40
- response=json.dumps(data),
41
- status=HTTPStatus.INTERNAL_SERVER_ERROR,
42
- mimetype='application/json'
43
- )
44
- return None
40
+ return Response(
41
+ response=json.dumps(data),
42
+ status=HTTPStatus.INTERNAL_SERVER_ERROR,
43
+ mimetype='application/json'
44
+ )
45
45
 
46
46
  def handle_error(resp, status):
47
47
  if is_http_status_internal(resp.status_code):
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: atk_common
3
- Version: 1.17.0
3
+ Version: 1.19.0
4
4
  Summary: ATK common methods
5
5
  Home-page: https://github.com/pypa/atk_common
6
6
  Author: Roger
@@ -25,5 +25,17 @@ Description-Content-Type: text/markdown
25
25
  License-File: license.txt
26
26
  Requires-Dist: kombu>=5.4.2
27
27
  Requires-Dist: requests>=2.32.3
28
+ Dynamic: author
29
+ Dynamic: author-email
30
+ Dynamic: classifier
31
+ Dynamic: description
32
+ Dynamic: description-content-type
33
+ Dynamic: home-page
34
+ Dynamic: keywords
35
+ Dynamic: license-file
36
+ Dynamic: project-url
37
+ Dynamic: requires-dist
38
+ Dynamic: requires-python
39
+ Dynamic: summary
28
40
 
29
41
  This package contains atk enforcement common entities and components
@@ -1,6 +1,8 @@
1
1
  import unittest
2
2
  import sys, os
3
- from atk_common.docker_utils import get_current_container_info
3
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'src')))
4
+ from atk_common import *
5
+ from atk_common.enums import *
4
6
 
5
7
  class TestDockerUtils(unittest.TestCase):
6
8
 
@@ -0,0 +1,28 @@
1
+ import unittest
2
+ from http import HTTPStatus
3
+ import sys, os
4
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'src')))
5
+ from atk_common import *
6
+ from atk_common.enums import *
7
+
8
+ class TestErrorUtils(unittest.TestCase):
9
+
10
+ def create_dummy_container_info(self):
11
+ data = {}
12
+ data['imageName'] = 'bo-test-api'
13
+ data['imageVersion'] = '1.0.0'
14
+ data['containerName'] = 'bo-test-api'
15
+ data['ports'] = []
16
+ data['ports'].append({'port': 8080, 'binding': 8080})
17
+ return data
18
+
19
+ def test_get_error_entity_enum(self):
20
+ http_response = get_error_entity('An new error occured', 'get-configuration', ApiErrorType.INTERNAL, HTTPStatus.INTERNAL_SERVER_ERROR, self.create_dummy_container_info())
21
+ self.assertIsNotNone(http_response)
22
+
23
+ def test_get_error_entity_enum_value(self):
24
+ http_response = get_error_entity('An new error occured', 'get-configuration', ApiErrorType.INTERNAL.value, HTTPStatus.INTERNAL_SERVER_ERROR, self.create_dummy_container_info())
25
+ self.assertIsNotNone(http_response)
26
+
27
+ if __name__ == "__main__":
28
+ unittest.main()
@@ -1,6 +1,8 @@
1
1
  import unittest
2
2
  import sys, os
3
- from atk_common.http_utils import get_test_response
3
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'src')))
4
+ from atk_common import *
5
+ from atk_common.enums import *
4
6
 
5
7
  class TestHttpUtils(unittest.TestCase):
6
8
 
@@ -1,6 +1,8 @@
1
1
  import unittest
2
2
  import sys, os
3
- from atk_common.log_utils import add_log_item
3
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'src')))
4
+ from atk_common import *
5
+ from atk_common.enums import *
4
6
 
5
7
  class TestLogUtils(unittest.TestCase):
6
8
 
@@ -1,21 +0,0 @@
1
- import unittest
2
- import sys, os
3
- from atk_common.error_utils import get_error_entity
4
-
5
- class TestErrorUtils(unittest.TestCase):
6
-
7
- def create_dummy_container_info(self):
8
- data = {}
9
- data['imageName'] = 'bo-test-api'
10
- data['imageVersion'] = '1.0.0'
11
- data['containerName'] = 'bo-test-api'
12
- data['ports'] = []
13
- data['ports'].append({'port': 8080, 'binding': 8080})
14
- return data
15
-
16
- def test_get_error_entity(self):
17
- resp_json = get_error_entity(None, 'An new error occured', 'get-configuration', 1, 404, self.create_dummy_container_info())
18
- self.assertIsNone(resp_json)
19
-
20
- if __name__ == "__main__":
21
- unittest.main()
File without changes
File without changes
File without changes
File without changes