1import os 2 3from unit.control import Control 4from unit.option import option 5 6 7class ApplicationProto(Control): 8 application_type = None 9 10 def get_application_type(self): 11 current_test = ( 12 os.environ.get('PYTEST_CURRENT_TEST').split(':')[-1].split(' ')[0] 13 ) 14 15 return option.generated_tests.get(current_test, self.application_type) 16 17 def _load_conf(self, conf, **kwargs): 18 if 'applications' in conf: 19 for app in conf['applications'].keys(): 20 app_conf = conf['applications'][app] 21 22 for key in [ 23 'user', 24 'group', 25 'isolation', 26 'processes', 27 'threads', 28 ]: 29 if key in kwargs: 30 app_conf[key] = kwargs[key] 31 32 assert 'success' in self.conf(conf), 'load application configuration' 33