aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukasz Rajewski <lukasz.rajewski@t-mobile.pl>2024-02-20 21:36:31 +0100
committerLukasz Rajewski <lukasz.rajewski@t-mobile.pl>2024-02-22 09:48:25 +0000
commit3228d6345ab35bc62cc3630f1baf73b504115586 (patch)
tree7b532f7c851db73a195d80e56157a9e99901d669
parent99569a495242d681c16bd2e014c7554bbfa3d34c (diff)
Fix latest SDC distribution list retrieval (old API)
Distributions must be sorted when returned from SDC Issue-ID: TEST-404 Signed-off-by: Lukasz Rajewski <lukasz.rajewski@t-mobile.pl> Change-Id: I0bb916f304f047e90b7a310d00b32f7ce9dea1c5
-rw-r--r--src/onapsdk/sdc/service.py6
-rw-r--r--src/onapsdk/version.py2
-rw-r--r--tests/test_service.py5
-rw-r--r--tests/test_version.py2
4 files changed, 9 insertions, 6 deletions
diff --git a/src/onapsdk/sdc/service.py b/src/onapsdk/sdc/service.py
index 0457215..4682258 100644
--- a/src/onapsdk/sdc/service.py
+++ b/src/onapsdk/sdc/service.py
@@ -686,8 +686,10 @@ class Service(SdcResource): # pylint: disable=too-many-instance-attributes, too
if ('distributionStatusOfServiceList' in result
and len(result['distributionStatusOfServiceList']) > 0):
# API changed and the latest distribution is not added to the end
- # of distributions list but inserted as the first one.
- dist_status = result['distributionStatusOfServiceList'][0]
+ # of distributions list but comes in random order
+ dist_status = sorted(result['distributionStatusOfServiceList'],
+ key=lambda dist: dist["timestamp"],
+ reverse=True)[0]
self._distribution_id = dist_status['distributionID']
@classmethod
diff --git a/src/onapsdk/version.py b/src/onapsdk/version.py
index c5f376b..fcce060 100644
--- a/src/onapsdk/version.py
+++ b/src/onapsdk/version.py
@@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-__version__ = "13.0.2"
+__version__ = "13.0.3"
diff --git a/tests/test_service.py b/tests/test_service.py
index 1c8d5e9..f86269c 100644
--- a/tests/test_service.py
+++ b/tests/test_service.py
@@ -639,11 +639,12 @@ def test_load_metadata_bad_json(mock_send):
@mock.patch.object(Service, 'send_message_json')
def test_load_metadata_OK(mock_send):
mock_send.return_value = {'distributionStatusOfServiceList': [
- {'distributionID': "11"}, {'distributionID': "12"}]}
+ {'distributionID': "11", "timestamp": "2024-02-15 08:44:59.537 UTC"},
+ {'distributionID': "12", "timestamp": "2024-02-18 07:28:53.388 UTC"}]}
svc = Service()
svc.identifier = "1"
svc.load_metadata()
- assert svc._distribution_id == "11"
+ assert svc._distribution_id == "12"
mock_send.assert_called_once_with(
'GET', 'Get Metadata for ONAP-test-Service',
'https://sdc.api.fe.simpledemo.onap.org:30207/sdc1/feProxy/rest/v1/catalog/services/1/distribution',
diff --git a/tests/test_version.py b/tests/test_version.py
index 19299c1..23a3b9c 100644
--- a/tests/test_version.py
+++ b/tests/test_version.py
@@ -17,4 +17,4 @@ import onapsdk.version as version
def test_version():
"""Check version is the right one."""
- assert version.__version__ == '13.0.2'
+ assert version.__version__ == '13.0.3'