atk-common 1.18.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.
- {atk_common-1.18.0 → atk_common-1.19.0}/PKG-INFO +1 -1
- {atk_common-1.18.0 → atk_common-1.19.0}/setup.py +1 -1
- {atk_common-1.18.0 → atk_common-1.19.0}/src/atk_common/error_utils.py +9 -9
- {atk_common-1.18.0 → atk_common-1.19.0}/src/atk_common.egg-info/PKG-INFO +1 -1
- {atk_common-1.18.0 → atk_common-1.19.0}/tests/test_docker_utils.py +3 -1
- atk_common-1.19.0/tests/test_error_utils.py +28 -0
- {atk_common-1.18.0 → atk_common-1.19.0}/tests/test_http_utils.py +3 -1
- {atk_common-1.18.0 → atk_common-1.19.0}/tests/test_log_utils.py +3 -1
- atk_common-1.18.0/tests/test_error_utils.py +0 -21
- {atk_common-1.18.0 → atk_common-1.19.0}/README.md +0 -0
- {atk_common-1.18.0 → atk_common-1.19.0}/license.txt +0 -0
- {atk_common-1.18.0 → atk_common-1.19.0}/pyproject.toml +0 -0
- {atk_common-1.18.0 → atk_common-1.19.0}/setup.cfg +0 -0
- {atk_common-1.18.0 → atk_common-1.19.0}/src/atk_common/__init__.py +0 -0
- {atk_common-1.18.0 → atk_common-1.19.0}/src/atk_common/datetime_utils.py +0 -0
- {atk_common-1.18.0 → atk_common-1.19.0}/src/atk_common/db_utils.py +0 -0
- {atk_common-1.18.0 → atk_common-1.19.0}/src/atk_common/docker_utils.py +0 -0
- {atk_common-1.18.0 → atk_common-1.19.0}/src/atk_common/enums/__init__.py +0 -0
- {atk_common-1.18.0 → atk_common-1.19.0}/src/atk_common/enums/api_error_type_enum.py +0 -0
- {atk_common-1.18.0 → atk_common-1.19.0}/src/atk_common/enums/command_status_enum.py +0 -0
- {atk_common-1.18.0 → atk_common-1.19.0}/src/atk_common/enums/response_status_enum.py +0 -0
- {atk_common-1.18.0 → atk_common-1.19.0}/src/atk_common/enums/speed_control_status_enum.py +0 -0
- {atk_common-1.18.0 → atk_common-1.19.0}/src/atk_common/env_utils.py +0 -0
- {atk_common-1.18.0 → atk_common-1.19.0}/src/atk_common/http_utils.py +0 -0
- {atk_common-1.18.0 → atk_common-1.19.0}/src/atk_common/log_utils.py +0 -0
- {atk_common-1.18.0 → atk_common-1.19.0}/src/atk_common/mq_utils.py +0 -0
- {atk_common-1.18.0 → atk_common-1.19.0}/src/atk_common/rabbitmq_consumer.py +0 -0
- {atk_common-1.18.0 → atk_common-1.19.0}/src/atk_common/response_utils.py +0 -0
- {atk_common-1.18.0 → atk_common-1.19.0}/src/atk_common.egg-info/SOURCES.txt +0 -0
- {atk_common-1.18.0 → atk_common-1.19.0}/src/atk_common.egg-info/dependency_links.txt +0 -0
- {atk_common-1.18.0 → atk_common-1.19.0}/src/atk_common.egg-info/requires.txt +0 -0
- {atk_common-1.18.0 → atk_common-1.19.0}/src/atk_common.egg-info/top_level.txt +0 -0
- {atk_common-1.18.0 → atk_common-1.19.0}/src/shared_python_atk_enforcement/__init__.py +0 -0
@@ -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.
|
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(
|
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
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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,8 @@
|
|
1
1
|
import unittest
|
2
2
|
import sys, os
|
3
|
-
|
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
|
-
|
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
|
-
|
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
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|