proto.py (1654:fc7d0578e124) proto.py (1670:099c23b00eaf)
1import os
2import re
3import time
4
5from conftest import option
6from unit.control import TestControl
7
8
9class TestApplicationProto(TestControl):
1import os
2import re
3import time
4
5from conftest import option
6from unit.control import TestControl
7
8
9class TestApplicationProto(TestControl):
10 application_type = None
11
10 def sec_epoch(self):
11 return time.mktime(time.gmtime())
12
13 def date_to_sec_epoch(self, date, template='%a, %d %b %Y %H:%M:%S %Z'):
14 return time.mktime(time.strptime(date, template))
15
16 def search_in_log(self, pattern, name='unit.log'):
17 with open(option.temp_dir + '/' + name, 'r', errors='ignore') as f:

--- 5 unchanged lines hidden (view full) ---

23
24 if found is not None:
25 break
26
27 time.sleep(0.1)
28
29 return found
30
12 def sec_epoch(self):
13 return time.mktime(time.gmtime())
14
15 def date_to_sec_epoch(self, date, template='%a, %d %b %Y %H:%M:%S %Z'):
16 return time.mktime(time.strptime(date, template))
17
18 def search_in_log(self, pattern, name='unit.log'):
19 with open(option.temp_dir + '/' + name, 'r', errors='ignore') as f:

--- 5 unchanged lines hidden (view full) ---

25
26 if found is not None:
27 break
28
29 time.sleep(0.1)
30
31 return found
32
31 def get_appication_type(self):
33 def get_application_type(self):
32 current_test = (
33 os.environ.get('PYTEST_CURRENT_TEST').split(':')[-1].split(' ')[0]
34 )
35
34 current_test = (
35 os.environ.get('PYTEST_CURRENT_TEST').split(':')[-1].split(' ')[0]
36 )
37
36 if current_test in option.generated_tests:
37 return option.generated_tests[current_test]
38 return option.generated_tests.get(current_test, self.application_type)
38
39
39 return None
40
41 def _load_conf(self, conf, **kwargs):
42 if 'applications' in conf:
43 for app in conf['applications'].keys():
44 app_conf = conf['applications'][app]
45 if 'user' in kwargs:
46 app_conf['user'] = kwargs['user']
47
48 if 'group' in kwargs:
49 app_conf['group'] = kwargs['group']
50
51 if 'isolation' in kwargs:
52 app_conf['isolation'] = kwargs['isolation']
53
54 assert 'success' in self.conf(conf), 'load application configuration'
40 def _load_conf(self, conf, **kwargs):
41 if 'applications' in conf:
42 for app in conf['applications'].keys():
43 app_conf = conf['applications'][app]
44 if 'user' in kwargs:
45 app_conf['user'] = kwargs['user']
46
47 if 'group' in kwargs:
48 app_conf['group'] = kwargs['group']
49
50 if 'isolation' in kwargs:
51 app_conf['isolation'] = kwargs['isolation']
52
53 assert 'success' in self.conf(conf), 'load application configuration'