X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=tests%2Funit%2Ftest_ocloud.py;h=a2904b7d448574351ff74f5c9315117a47110b7d;hb=84867b76a65efc4e9add52c86eae7e451c4a038d;hp=a98f0db48f17c8c229dfbe2013caced095a592fd;hpb=5c501cb5e57a1ac3e0e7d38e22a3759e7958777a;p=pti%2Fo2.git diff --git a/tests/unit/test_ocloud.py b/tests/unit/test_ocloud.py index a98f0db..a2904b7 100644 --- a/tests/unit/test_ocloud.py +++ b/tests/unit/test_ocloud.py @@ -17,7 +17,7 @@ import uuid from o2ims.domain import ocloud from o2ims.domain import resource_type as rt from o2ims.views import ocloud_view -from o2ims import config +from o2common.config import config def setup_ocloud(): @@ -34,16 +34,16 @@ def test_new_ocloud(): assert ocloudid1 is not None and ocloud1.oCloudId == ocloudid1 -def test_add_ocloud_with_dms(): - ocloud1 = setup_ocloud() - dmsid = str(uuid.uuid4()) - dms = ocloud.DeploymentManager( - dmsid, "k8s1", ocloud1.oCloudId, config.get_api_url()+"/k8s1") - ocloud1.addDeploymentManager(dms) - ocloud1.addDeploymentManager(dms) - assert len(ocloud1.deploymentManagers) == 1 - # repo.update(ocloud1.oCloudId, { - # "deploymentManagers": ocloud1.deploymentManagers}) +# def test_add_ocloud_with_dms(): +# ocloud1 = setup_ocloud() +# dmsid = str(uuid.uuid4()) +# dms = ocloud.DeploymentManager( +# dmsid, "k8s1", ocloud1.oCloudId, config.get_api_url()+"/k8s1") +# ocloud1.addDeploymentManager(dms) +# ocloud1.addDeploymentManager(dms) +# assert len(ocloud1.deploymentManagers) == 1 +# # repo.update(ocloud1.oCloudId, { +# # "deploymentManagers": ocloud1.deploymentManagers}) def test_new_resource_type(): @@ -261,8 +261,8 @@ def test_view_subscriptions(mock_uow): "subscriptionId": subscription_id1, }] - deployment_manager_list = ocloud_view.subscriptions(uow) - assert str(deployment_manager_list[0].get( + subscription_list = ocloud_view.subscriptions(uow) + assert str(subscription_list[0].get( "subscriptionId")) == subscription_id1 @@ -273,18 +273,18 @@ def test_view_subscription_one(mock_uow): session.return_value.execute.return_value.first.return_value = None # Query return None - deployment_manager_res = ocloud_view.subscription_one( + subscription_res = ocloud_view.subscription_one( subscription_id1, uow) - assert deployment_manager_res is None + assert subscription_res is None session.return_value.execute.return_value.first.return_value = { - "deploymentManagerId": subscription_id1, + "subscriptionId": subscription_id1, } - deployment_manager_res = ocloud_view.subscription_one( + subscription_res = ocloud_view.subscription_one( subscription_id1, uow) - assert str(deployment_manager_res.get( - "deploymentManagerId")) == subscription_id1 + assert str(subscription_res.get( + "subscriptionId")) == subscription_id1 def test_flask_get_list(mock_flask_uow): @@ -294,9 +294,6 @@ def test_flask_get_list(mock_flask_uow): # Get list and return empty list ########################## - resp = client.get(apibase+"/") - assert resp.get_data() == b'[]\n' - resp = client.get(apibase+"/resourceTypes") assert resp.get_data() == b'[]\n' @@ -318,6 +315,9 @@ def test_flask_get_one(mock_flask_uow): # Get one and return 404 ########################### + resp = client.get(apibase+"/") + assert resp.status_code == 404 + resource_type_id1 = str(uuid.uuid4()) resp = client.get(apibase+"/resourceTypes/"+resource_type_id1) assert resp.status_code == 404 @@ -440,8 +440,6 @@ def test_flask_not_allowed(mock_flask_uow): # Testing subscriptions not support method ########################## uri = apibase + "/subscriptions" - resp = client.post(uri) - assert resp.status == '405 METHOD NOT ALLOWED' resp = client.put(uri) assert resp.status == '405 METHOD NOT ALLOWED' resp = client.patch(uri) @@ -457,5 +455,3 @@ def test_flask_not_allowed(mock_flask_uow): assert resp.status == '405 METHOD NOT ALLOWED' resp = client.patch(uri) assert resp.status == '405 METHOD NOT ALLOWED' - resp = client.delete(uri) - assert resp.status == '405 METHOD NOT ALLOWED'