summaryrefslogtreecommitdiffstats
path: root/components/pm-subscription-handler/tests
diff options
context:
space:
mode:
authorefiacor <fiachra.corcoran@est.tech>2020-02-12 23:31:16 +0000
committerefiacor <fiachra.corcoran@est.tech>2020-02-13 13:27:07 +0000
commitbc9f41ed3e67ed0350951de62331b3cd87c6aa78 (patch)
tree2d98fec426d48a3fd2bed9d01db2c9b2d50ae1ad /components/pm-subscription-handler/tests
parent296f6a9817c28d9453fe697ae3dae6af37610eec (diff)
Fix PMHS logs dir setup
# Refactoring test|prod init Signed-off-by: efiacor <fiachra.corcoran@est.tech> Change-Id: Ib073cb762a7750fca7bdf415cf5080d04f7bda51 Issue-ID: DCAEGEN2-2078
Diffstat (limited to 'components/pm-subscription-handler/tests')
-rwxr-xr-xcomponents/pm-subscription-handler/tests/test_network_function.py12
-rwxr-xr-xcomponents/pm-subscription-handler/tests/test_subscription.py10
2 files changed, 16 insertions, 6 deletions
diff --git a/components/pm-subscription-handler/tests/test_network_function.py b/components/pm-subscription-handler/tests/test_network_function.py
index 2af1489b..267851d2 100755
--- a/components/pm-subscription-handler/tests/test_network_function.py
+++ b/components/pm-subscription-handler/tests/test_network_function.py
@@ -16,17 +16,23 @@
# SPDX-License-Identifier: Apache-2.0
# ============LICENSE_END=====================================================
import unittest
+from test.support import EnvironmentVarGuard
+from unittest import mock
-from mod import db, create_test_app
+from mod import db, create_app
from mod.network_function import NetworkFunction
class NetworkFunctionTests(unittest.TestCase):
- def setUp(self):
+ @mock.patch('mod.get_db_connection_url')
+ def setUp(self, mock_get_db_url):
+ mock_get_db_url.return_value = 'sqlite://'
self.nf_1 = NetworkFunction(nf_name='pnf_1', orchestration_status='Inventoried')
self.nf_2 = NetworkFunction(nf_name='pnf_2', orchestration_status='Active')
- self.app = create_test_app()
+ self.env = EnvironmentVarGuard()
+ self.env.set('LOGS_PATH', './unit_test_logs')
+ self.app = create_app()
self.app_context = self.app.app_context()
self.app_context.push()
db.create_all()
diff --git a/components/pm-subscription-handler/tests/test_subscription.py b/components/pm-subscription-handler/tests/test_subscription.py
index 3c7651d4..97c1d6a1 100755
--- a/components/pm-subscription-handler/tests/test_subscription.py
+++ b/components/pm-subscription-handler/tests/test_subscription.py
@@ -24,15 +24,17 @@ from unittest import mock
from requests import Session
import mod.aai_client as aai_client
-from mod import db, create_test_app
+from mod import db, create_app
from mod.network_function import NetworkFunction
from mod.subscription import Subscription, NetworkFunctionFilter
class SubscriptionTest(unittest.TestCase):
+ @mock.patch('mod.get_db_connection_url')
@mock.patch.object(Session, 'put')
- def setUp(self, mock_session):
+ def setUp(self, mock_session, mock_get_db_url):
+ mock_get_db_url.return_value = 'sqlite://'
with open(os.path.join(os.path.dirname(__file__), 'data/aai_xnfs.json'), 'r') as data:
self.aai_response_data = data.read()
mock_session.return_value.status_code = 200
@@ -40,6 +42,8 @@ class SubscriptionTest(unittest.TestCase):
self.env = EnvironmentVarGuard()
self.env.set('AAI_SERVICE_HOST', '1.2.3.4')
self.env.set('AAI_SERVICE_PORT_AAI_SSL', '8443')
+ self.env.set('TESTING', 'True')
+ self.env.set('LOGS_PATH', './unit_test_logs')
with open(os.path.join(os.path.dirname(__file__), 'data/cbs_data_1.json'), 'r') as data:
self.cbs_data_1 = json.load(data)
with open(os.path.join(os.path.dirname(__file__),
@@ -50,7 +54,7 @@ class SubscriptionTest(unittest.TestCase):
self.nf_1 = NetworkFunction(nf_name='pnf_1', orchestration_status='Inventoried')
self.nf_2 = NetworkFunction(nf_name='pnf_2', orchestration_status='Active')
self.xnf_filter = NetworkFunctionFilter(**self.sub_1.nfFilter)
- self.app = create_test_app()
+ self.app = create_app()
self.app_context = self.app.app_context()
self.app_context.push()
db.create_all()