Files
test/automated-robot-suite/Variables/config_init.py
Jose Perez Carranza 2d3d047a8c [robot] Add libraries and resources used by the suite
Add a series of libraries and resources that are used by the suite setup
and test cases functionality.

-  Libraries - Libraries written in python mostly to serve the
        installation and deployment of StarlingX from robot test cases.
-  Resources – Libraries in robot format that are used as a
         pool of keywords to be used by the entire set of test
         cases.
-  Utils – Libraries written in python that expose
         functionality to configure the framework at host
         machine level.
-  Variables – Global variables that are
          used to setup the framework as well as
          test cases.

Story: 2004828
Task: 29004

Depends-On: I6ead335412150fb8d64a6abf7909cf702d0d248c
Change-Id: I796dcaf71089424dd37a050691fd0ee003ad3176
Signed-off-by: Jose Perez Carranza <jose.perez.carranza@intel.com>
2019-08-20 20:51:35 +00:00

33 lines
1021 B
Python

"""Provides a library of useful utilities for Robot Framework"""
import configparser
def get_variables(var_name, config_file):
"""Get variables from a config.ini
This function parse a config.ini file and return a dict
with their values for use with Robot Framework as variables
:param var_name: the variable used for make reference in robot, e.g:
*** Settings ***
Variables Variables/ConfigInit.py Config %{PYTHONPATH}/Config/config.ini
*** Variables ***
${kernel_option} ${CONFIG.iso_installer.KERNEL_OPTION}
:param config_file: the config.ini to parse
:return
- variables: the dict with all values from config.init
"""
configurations = configparser.ConfigParser()
configurations.read(config_file)
variables = dict()
for section in configurations.sections():
for key, value in configurations.items(section):
var = '{}.{}.{}'.format(var_name, section, key)
variables[var] = str(value)
return variables