From 54837759f36eddb80af22c8d73e103a948221dc7 Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Mon, 19 Oct 2020 22:25:29 +0100 Subject: Tests: fixed unit.log print. --- test/test_php_application.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'test/test_php_application.py') diff --git a/test/test_php_application.py b/test/test_php_application.py index 063d3e0c..f1a9e293 100644 --- a/test/test_php_application.py +++ b/test/test_php_application.py @@ -6,6 +6,7 @@ import time import pytest from conftest import option +from conftest import unit_stop from unit.applications.lang.php import TestApplicationPHP class TestPHPApplication(TestApplicationPHP): @@ -444,7 +445,7 @@ class TestPHPApplication(TestApplicationPHP): r'012345', self.get()['body'] ), 'disable_classes before' - def test_php_application_error_log(self): + def test_php_application_error_log(self, temp_dir): self.load('error_log') assert self.get()['status'] == 200, 'status' @@ -453,13 +454,13 @@ class TestPHPApplication(TestApplicationPHP): assert self.get()['status'] == 200, 'status 2' - self.stop() + unit_stop() 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' - with open(self.temp_dir + '/unit.log', 'r', errors='ignore') as f: + with open(temp_dir + '/unit.log', 'r', errors='ignore') as f: errs = re.findall(pattern, f.read()) assert len(errs) == 2, 'error_log count' @@ -507,12 +508,12 @@ class TestPHPApplication(TestApplicationPHP): assert resp['status'] == 200, 'status' assert resp['body'] != '', 'body not empty' - def test_php_application_extension_check(self): + def test_php_application_extension_check(self, temp_dir): self.load('phpinfo') assert self.get(url='/index.wrong')['status'] != 200, 'status' - new_root = self.temp_dir + "/php" + new_root = temp_dir + "/php" os.mkdir(new_root) shutil.copy(option.test_dir + '/php/phpinfo/index.wrong', new_root) -- cgit From a0ee50826a4810595123460ed11629f87b1995a0 Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Wed, 11 Nov 2020 14:24:40 +0000 Subject: Tests: added a test for fastcgi_finish_request() function. --- test/test_php_application.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test/test_php_application.py') diff --git a/test/test_php_application.py b/test/test_php_application.py index f1a9e293..578de0b7 100644 --- a/test/test_php_application.py +++ b/test/test_php_application.py @@ -94,6 +94,32 @@ class TestPHPApplication(TestApplicationPHP): assert resp['status'] == 200, 'query string empty status' assert resp['headers']['Query-String'] == '', 'query string empty' + def test_php_application_fastcgi_finish_request(self, temp_dir): + self.load('fastcgi_finish_request') + + assert self.get()['body'] == '0123' + + unit_stop() + + with open(temp_dir + '/unit.log', 'r', errors='ignore') as f: + errs = re.findall(r'Error in fastcgi_finish_request', f.read()) + + assert len(errs) == 0, 'no error' + + def test_php_application_fastcgi_finish_request_2(self, temp_dir): + self.load('fastcgi_finish_request') + + resp = self.get(url='/?skip') + assert resp['status'] == 200 + assert resp['body'] == '' + + unit_stop() + + with open(temp_dir + '/unit.log', 'r', errors='ignore') as f: + errs = re.findall(r'Error in fastcgi_finish_request', f.read()) + + assert len(errs) == 0, 'no error' + def test_php_application_query_string_absent(self): self.load('query_string') -- cgit