blob: 2e50dde9d35b1a00020628a38dee8970fe2807f4 [file] [log] [blame]
efiacor0080fa42020-09-08 16:26:50 +01001# ============LICENSE_START===================================================
2# Copyright (C) 2020 Nordix Foundation.
3# ============================================================================
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16# SPDX-License-Identifier: Apache-2.0
17# ============LICENSE_END=====================================================
18import json
19import os
20from unittest import TestCase
21from unittest.mock import patch, MagicMock
22
23from mod import create_app, db
24from mod.pmsh_utils import AppConfig
25
26
27def get_pmsh_config():
28 with open(os.path.join(os.path.dirname(__file__), 'data/cbs_data_1.json'), 'r') as data:
29 return json.load(data)
30
31
32class BaseClassSetup(TestCase):
33 app = None
34 app_context = None
35
36 @classmethod
37 @patch('mod.get_db_connection_url', MagicMock(return_value='sqlite://'))
38 @patch('mod.update_logging_config', MagicMock())
39 def setUpClass(cls):
40 os.environ['LOGGER_CONFIG'] = os.path.join(os.path.dirname(__file__), 'log_config.yaml')
41 os.environ['LOGS_PATH'] = '.'
42 cls.app = create_app()
43 cls.app_context = cls.app.app_context()
44 cls.app_context.push()
45
46 @patch('mod.pmsh_utils.AppConfig._get_pmsh_config', MagicMock(return_value=get_pmsh_config()))
47 def setUp(self):
48 os.environ['AAI_SERVICE_PORT'] = '8443'
49 db.create_all()
50 self.app_conf = AppConfig()
51
52 def tearDown(self):
53 db.drop_all()
54
55 @classmethod
56 def tearDownClass(cls):
57 db.session.remove()