Tests: more fixtures.

Common methods from applications/proto.py converted to the fixtures.
sysctl check moved to the specific file where it is using.
Some options moved to the constructor to have early access.
This commit is contained in:
Andrei Zeliankou
2023-05-29 16:45:49 +01:00
parent f55818059c
commit 31ff94add9
24 changed files with 340 additions and 341 deletions

View File

@@ -53,7 +53,7 @@ opcache.preload_user = {option.user or getpass.getuser()}
'applications/opcache/options',
)
def test_php_application_variables(self):
def test_php_application_variables(self, date_to_sec_epoch, sec_epoch):
self.load('variables')
body = 'Test body string.'
@@ -79,9 +79,7 @@ opcache.preload_user = {option.user or getpass.getuser()}
date = headers.pop('Date')
assert date[-4:] == ' GMT', 'date header timezone'
assert (
abs(self.date_to_sec_epoch(date) - self.sec_epoch()) < 5
), 'date header'
assert abs(date_to_sec_epoch(date) - sec_epoch) < 5, 'date header'
if 'X-Powered-By' in headers:
headers.pop('X-Powered-By')
@@ -116,7 +114,7 @@ opcache.preload_user = {option.user or getpass.getuser()}
assert resp['status'] == 200, 'query string empty status'
assert resp['headers']['Query-String'] == '', 'query string empty'
def test_php_application_fastcgi_finish_request(self, unit_pid):
def test_php_application_fastcgi_finish_request(self, findall, unit_pid):
self.load('fastcgi_finish_request')
assert 'success' in self.conf(
@@ -128,11 +126,11 @@ opcache.preload_user = {option.user or getpass.getuser()}
os.kill(unit_pid, signal.SIGUSR1)
errs = self.findall(r'Error in fastcgi_finish_request')
errs = findall(r'Error in fastcgi_finish_request')
assert len(errs) == 0, 'no error'
def test_php_application_fastcgi_finish_request_2(self, unit_pid):
def test_php_application_fastcgi_finish_request_2(self, findall, unit_pid):
self.load('fastcgi_finish_request')
assert 'success' in self.conf(
@@ -146,7 +144,7 @@ opcache.preload_user = {option.user or getpass.getuser()}
os.kill(unit_pid, signal.SIGUSR1)
errs = self.findall(r'Error in fastcgi_finish_request')
errs = findall(r'Error in fastcgi_finish_request')
assert len(errs) == 0, 'no error'
@@ -556,7 +554,7 @@ opcache.preload_user = {option.user or getpass.getuser()}
r'012345', self.get()['body']
), 'disable_classes before'
def test_php_application_error_log(self):
def test_php_application_error_log(self, findall, wait_for_record):
self.load('error_log')
assert self.get()['status'] == 200, 'status'
@@ -567,9 +565,9 @@ opcache.preload_user = {option.user or getpass.getuser()}
pattern = r'\d{4}\/\d\d\/\d\d\s\d\d:.+\[notice\].+Error in application'
assert self.wait_for_record(pattern) is not None, 'errors print'
assert wait_for_record(pattern) is not None, 'errors print'
errs = self.findall(pattern)
errs = findall(pattern)
assert len(errs) == 2, 'error_log count'