2 ##############################################################################
3 # Copyright (c) 2019 AT&T Intellectual Property. #
4 # Copyright (c) 2019 Nokia. #
6 # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7 # not use this file except in compliance with the License. #
9 # You may obtain a copy of the License at #
10 # http://www.apache.org/licenses/LICENSE-2.0 #
12 # Unless required by applicable law or agreed to in writing, software #
13 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT #
14 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
15 # See the License for the specific language governing permissions and #
16 # limitations under the License. #
17 ##############################################################################
18 """This module parses yaml file, reads sections, testcases and executes each
26 def run_testcase(testcase):
27 """Runs a single testcase
29 show_stopper = testcase.get('show_stopper', False)
31 print('Executing testcase {}'.format(testcase['name']))
32 print(' show_stopper {}'.format(show_stopper))
33 cmd = 'robot {}'.format(testcase['what'])
34 print('Invoking {}'.format(cmd))
36 status = subprocess.call(cmd, shell=True)
37 if status != 0 and show_stopper:
38 print('Show stopper testcase failed')
41 print('Error while executing {}'.format(cmd))
46 def parse_yaml(testcase_loc):
47 """Parse yaml file and do tasks on each testcase
49 with open(testcase_loc) as testcase_file:
50 testcases = yaml.safe_load(testcase_file)
51 blueprint = testcases['blueprint']
52 for section in blueprint['sections']:
53 print('## Section {}'.format(section))
54 for testcase in blueprint[section]:
55 run_testcase(testcase)
58 if __name__ == "__main__":
59 if len(sys.argv) != 2:
60 print('usage: bluval.py <testcase.yaml>')
62 parse_yaml(sys.argv[1])