1 # ============LICENSE_START===============================================
2 # Copyright (C) 2020 Nordix Foundation. All rights reserved.
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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 # ============LICENSE_END=================================================
18 # Setting up dir and env for unit test of simualators
23 #Server port and base path
26 SERVER_URL="http://"+HOST_IP+":"+PORT_NUMBER+"/"
28 # Dir for json test data files
31 def setup_env(interface_version):
34 # Env TESTS_BASE_PATH is set when executed via tox.ini
35 # If basic test is executed from cmd line, that env var is not needed
36 if 'TESTS_BASE_PATH' in os.environ:
37 cwd=os.environ['TESTS_BASE_PATH']+"/"
38 testdata=cwd+"../test/"+interface_version+"/jsonfiles/"
40 #Env var to setup version and host logging
41 os.environ['APIPATH'] = cwd+"../api/"+interface_version
42 os.environ['REMOTE_HOSTS_LOGGING'] = "ON"
43 os.environ['DUPLICATE_CHECK'] = "0"
45 # Paths need to run the sim, including needed source file dirs
46 sys.path.append(os.path.abspath(cwd+'../src/common'))
47 sys.path.append(os.path.abspath(cwd+'../test/common'))
48 sys.path.append(os.path.abspath(cwd+'../src/'+interface_version))
49 os.chdir(cwd+"../src/"+interface_version)
51 def get_testdata_dir():
54 # Test client for rest calls
58 with app.app.test_client() as client:
61 # Run the Flask app in a separate thread for testing
64 app.app.run(port=8086, host="127.0.0.1")