X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=catalog%2Fpackages%2Ftests%2Ftest_vnf_pkg_subscription.py;h=d2e2b5b2c4e1bd3ae9aaa1e3592b559d003b9722;hb=c0fcb2e4cde1cd5338412e5ce83115626d068f7b;hp=bc7ee49727ad5d2dd71e194150679edcfa72b2f5;hpb=b7d87af11036d724710a50116fd3edabe25afd5b;p=modeling%2Fetsicatalog.git diff --git a/catalog/packages/tests/test_vnf_pkg_subscription.py b/catalog/packages/tests/test_vnf_pkg_subscription.py index bc7ee49..d2e2b5b 100644 --- a/catalog/packages/tests/test_vnf_pkg_subscription.py +++ b/catalog/packages/tests/test_vnf_pkg_subscription.py @@ -12,23 +12,25 @@ # See the License for the specific language governing permissions and # limitations under the License. -import uuid -import mock import json import os +import uuid -from rest_framework.test import APIClient +import mock from django.test import TestCase +from rest_framework import status +from rest_framework.test import APIClient -from catalog.pub.database.models import VnfPkgSubscriptionModel, VnfPackageModel -from .const import vnf_subscription_data, vnfd_data -from catalog.packages.biz.notificationsutil import PkgNotifications +import catalog.pub.utils.timeutil from catalog.packages import const +from catalog.packages.biz.notificationsutil import PkgNotifications +from catalog.packages.biz.vnf_pkg_subscription import QuerySubscription, TerminateSubscription from catalog.pub.config import config as pub_config -import catalog.pub.utils.timeutil -from catalog.pub.utils import toscaparser from catalog.pub.config.config import CATALOG_ROOT_PATH -from rest_framework import status +from catalog.pub.database.models import VnfPkgSubscriptionModel, VnfPackageModel +from catalog.pub.exceptions import SubscriptionDoesNotExistsException +from catalog.pub.utils import toscaparser +from .const import vnf_subscription_data, vnfd_data class TestNfPackageSubscription(TestCase): @@ -196,7 +198,8 @@ class TestNfPackageSubscription(TestCase): @mock.patch("requests.post") @mock.patch("uuid.uuid4") @mock.patch.object(catalog.pub.utils.timeutil, "now_time") - def test_vnfpkg_subscript_notify(self, mock_nowtime, mock_uuid, mock_requests_post, mock_parse_vnfd, mock_requests_get): + def test_vnfpkg_subscript_notify(self, mock_nowtime, mock_uuid, mock_requests_post, mock_parse_vnfd, + mock_requests_get): mock_nowtime.return_value = "2019-02-16 14:41:16" uuid_subscriptid = "99442b18-a5c7-11e8-998c-bf1755941f13" uuid_vnfPackageId = "3fa85f64-5717-4562-b3fc-2c963f66afa6" @@ -247,6 +250,20 @@ class TestNfPackageSubscription(TestCase): mock_requests_post.assert_called_with(vnf_subscription_data["callbackUri"], data=expect_notification, headers={'Connection': 'close'}) + def test_service_query_single_subscription_not_found(self): + try: + subscription_id = "test_not_found" + QuerySubscription().query_single_subscription(subscription_id) + except SubscriptionDoesNotExistsException as e: + self.assertEqual("Subscription with ID: %s does not exist" % subscription_id, e.args[0]) + + def test_service_delete_single_subscription_not_found(self): + try: + subscription_id = "test_not_found" + TerminateSubscription().terminate(subscription_id) + except SubscriptionDoesNotExistsException as e: + self.assertEqual("Subscription with ID: %s does not exist" % subscription_id, e.args[0]) + class NotificationTest(TestCase): def setUp(self): @@ -301,4 +318,5 @@ class NotificationTest(TestCase): } } } - mock_requests_post.assert_called_with(expect_callbackuri, data=expect_notification, headers={'Connection': 'close'}) + mock_requests_post.assert_called_with(expect_callbackuri, data=expect_notification, + headers={'Connection': 'close'})