summaryrefslogtreecommitdiffhomepage
path: root/test/test_ruby_application.py
diff options
context:
space:
mode:
authorAndrei Zeliankou <zelenkov@nginx.com>2023-05-29 16:45:49 +0100
committerAndrei Zeliankou <zelenkov@nginx.com>2023-05-29 16:45:49 +0100
commit31ff94add9c4043a753683d9e8b68733c69aa1ac (patch)
tree1737c36a2641129a4de775c6058cc07b9cdca0f6 /test/test_ruby_application.py
parentf55818059c01ff9e61bee8107ed1389fe272a787 (diff)
downloadunit-31ff94add9c4043a753683d9e8b68733c69aa1ac.tar.gz
unit-31ff94add9c4043a753683d9e8b68733c69aa1ac.tar.bz2
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.
Diffstat (limited to 'test/test_ruby_application.py')
-rw-r--r--test/test_ruby_application.py31
1 files changed, 14 insertions, 17 deletions
diff --git a/test/test_ruby_application.py b/test/test_ruby_application.py
index ecce86cb..166ca1ed 100644
--- a/test/test_ruby_application.py
+++ b/test/test_ruby_application.py
@@ -8,7 +8,7 @@ from unit.applications.lang.ruby import TestApplicationRuby
class TestRubyApplication(TestApplicationRuby):
prerequisites = {'modules': {'ruby': 'all'}}
- def test_ruby_application(self):
+ def test_ruby_application(self, date_to_sec_epoch, sec_epoch):
self.load('variables')
body = 'Test body string.'
@@ -33,9 +33,7 @@ class TestRubyApplication(TestApplicationRuby):
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'
assert headers == {
'Connection': 'close',
@@ -170,30 +168,30 @@ class TestRubyApplication(TestApplicationRuby):
assert self.get()['status'] == 500, 'syntax error'
- def test_ruby_application_errors_puts(self):
+ def test_ruby_application_errors_puts(self, wait_for_record):
self.load('errors_puts')
assert self.get()['status'] == 200
assert (
- self.wait_for_record(r'\[error\].+Error in application') is not None
+ wait_for_record(r'\[error\].+Error in application') is not None
), 'errors puts'
- def test_ruby_application_errors_puts_int(self):
+ def test_ruby_application_errors_puts_int(self, wait_for_record):
self.load('errors_puts_int')
assert self.get()['status'] == 200
assert (
- self.wait_for_record(r'\[error\].+1234567890') is not None
+ wait_for_record(r'\[error\].+1234567890') is not None
), 'errors puts int'
- def test_ruby_application_errors_write(self):
+ def test_ruby_application_errors_write(self, wait_for_record):
self.load('errors_write')
assert self.get()['status'] == 200
assert (
- self.wait_for_record(r'\[error\].+Error in application') is not None
+ wait_for_record(r'\[error\].+Error in application') is not None
), 'errors write'
def test_ruby_application_errors_write_to_s_custom(self):
@@ -201,15 +199,15 @@ class TestRubyApplication(TestApplicationRuby):
assert self.get()['status'] == 200, 'errors write to_s custom'
- def test_ruby_application_errors_write_int(self):
+ def test_ruby_application_errors_write_int(self, wait_for_record):
self.load('errors_write_int')
assert self.get()['status'] == 200
assert (
- self.wait_for_record(r'\[error\].+1234567890') is not None
+ wait_for_record(r'\[error\].+1234567890') is not None
), 'errors write int'
- def test_ruby_application_at_exit(self):
+ def test_ruby_application_at_exit(self, wait_for_record):
self.load('at_exit')
assert self.get()['status'] == 200
@@ -217,7 +215,7 @@ class TestRubyApplication(TestApplicationRuby):
assert 'success' in self.conf({"listeners": {}, "applications": {}})
assert (
- self.wait_for_record(r'\[error\].+At exit called\.') is not None
+ wait_for_record(r'\[error\].+At exit called\.') is not None
), 'at exit'
def test_ruby_application_encoding(self):
@@ -322,14 +320,13 @@ class TestRubyApplication(TestApplicationRuby):
assert self.post(body=body)['body'] == body, 'body large'
@pytest.mark.skip('not yet')
- def test_ruby_application_body_each_error(self):
+ def test_ruby_application_body_each_error(self, wait_for_record):
self.load('body_each_error')
assert self.get()['status'] == 500, 'body each error status'
assert (
- self.wait_for_record(r'\[error\].+Failed to run ruby script')
- is not None
+ wait_for_record(r'\[error\].+Failed to run ruby script') is not None
), 'body each error'
def test_ruby_application_body_file(self):