Tests: removed unused code in unit.py.
This commit is contained in:
@@ -4,10 +4,7 @@ import unit
|
|||||||
class TestUnitConfiguration(unit.TestUnitControl):
|
class TestUnitConfiguration(unit.TestUnitControl):
|
||||||
|
|
||||||
def setUpClass():
|
def setUpClass():
|
||||||
u = unit.TestUnit()
|
unit.TestUnit().check_modules('python')
|
||||||
|
|
||||||
u.check_modules('python')
|
|
||||||
u.check_version('0.5')
|
|
||||||
|
|
||||||
def test_json_leading_zero(self):
|
def test_json_leading_zero(self):
|
||||||
self.assertIn('error', self.conf('00'), 'leading zero')
|
self.assertIn('error', self.conf('00'), 'leading zero')
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
import unittest
|
import unittest
|
||||||
import unit
|
import unit
|
||||||
|
|
||||||
class TestUnitBasic(unit.TestUnitControl):
|
class TestUnitPHPBasic(unit.TestUnitControl):
|
||||||
|
|
||||||
def setUpClass():
|
def setUpClass():
|
||||||
u = unit.TestUnit()
|
unit.TestUnit().check_modules('php')
|
||||||
|
|
||||||
u.check_modules('php')
|
|
||||||
u.check_version('0.5')
|
|
||||||
|
|
||||||
conf_app = {
|
conf_app = {
|
||||||
"app": {
|
"app": {
|
||||||
|
|||||||
@@ -2,13 +2,10 @@ import time
|
|||||||
import unittest
|
import unittest
|
||||||
import unit
|
import unit
|
||||||
|
|
||||||
class TestUnitApplication(unit.TestUnitControl):
|
class TestUnitPythonApplication(unit.TestUnitControl):
|
||||||
|
|
||||||
def setUpClass():
|
def setUpClass():
|
||||||
u = unit.TestUnit()
|
unit.TestUnit().check_modules('python')
|
||||||
|
|
||||||
u.check_modules('python')
|
|
||||||
u.check_version('0.5')
|
|
||||||
|
|
||||||
def conf_with_name(self, name):
|
def conf_with_name(self, name):
|
||||||
self.conf({
|
self.conf({
|
||||||
|
|||||||
@@ -3,15 +3,12 @@ import time
|
|||||||
import unittest
|
import unittest
|
||||||
import unit
|
import unit
|
||||||
|
|
||||||
class TestUnitApplication(unit.TestUnitControl):
|
class TestUnitPythonAtExit(unit.TestUnitControl):
|
||||||
|
|
||||||
def setUpClass():
|
def setUpClass():
|
||||||
u = unit.TestUnit()
|
unit.TestUnit().check_modules('python')
|
||||||
|
|
||||||
u.check_modules('python')
|
def test_python_atexit(self):
|
||||||
u.check_version('0.5')
|
|
||||||
|
|
||||||
def test_python_application(self):
|
|
||||||
code, name = """
|
code, name = """
|
||||||
import atexit
|
import atexit
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
import unittest
|
import unittest
|
||||||
import unit
|
import unit
|
||||||
|
|
||||||
class TestUnitBasic(unit.TestUnitControl):
|
class TestUnitPythonBasic(unit.TestUnitControl):
|
||||||
|
|
||||||
def setUpClass():
|
def setUpClass():
|
||||||
u = unit.TestUnit()
|
unit.TestUnit().check_modules('python')
|
||||||
|
|
||||||
u.check_modules('python')
|
|
||||||
u.check_version('0.5')
|
|
||||||
|
|
||||||
conf_app = {
|
conf_app = {
|
||||||
"app": {
|
"app": {
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
import unittest
|
import unittest
|
||||||
import unit
|
import unit
|
||||||
|
|
||||||
class TestUnitApplication(unit.TestUnitControl):
|
class TestUnitPythonKeepalive(unit.TestUnitControl):
|
||||||
|
|
||||||
def setUpClass():
|
def setUpClass():
|
||||||
u = unit.TestUnit()
|
unit.TestUnit().check_modules('python')
|
||||||
|
|
||||||
u.check_modules('python')
|
|
||||||
u.check_version('0.5')
|
|
||||||
|
|
||||||
def test_python_keepalive_body(self):
|
def test_python_keepalive_body(self):
|
||||||
code, name = """
|
code, name = """
|
||||||
|
|||||||
@@ -4,13 +4,10 @@ import subprocess
|
|||||||
import unittest
|
import unittest
|
||||||
import unit
|
import unit
|
||||||
|
|
||||||
class TestUnitProcman(unit.TestUnitControl):
|
class TestUnitPythonProcman(unit.TestUnitControl):
|
||||||
|
|
||||||
def setUpClass():
|
def setUpClass():
|
||||||
u = unit.TestUnit()
|
unit.TestUnit().check_modules('python')
|
||||||
|
|
||||||
u.check_modules('python')
|
|
||||||
u.check_version('0.5')
|
|
||||||
|
|
||||||
def pids_for_process(self, process=None):
|
def pids_for_process(self, process=None):
|
||||||
if process is None:
|
if process is None:
|
||||||
|
|||||||
20
test/unit.py
20
test/unit.py
@@ -21,10 +21,6 @@ class TestUnit(unittest.TestCase):
|
|||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self._stop()
|
self._stop()
|
||||||
|
|
||||||
if '--log' in sys.argv:
|
|
||||||
with open(self.testdir + '/unit.log', 'r') as f:
|
|
||||||
print(f.read())
|
|
||||||
|
|
||||||
if '--leave' not in sys.argv:
|
if '--leave' not in sys.argv:
|
||||||
shutil.rmtree(self.testdir)
|
shutil.rmtree(self.testdir)
|
||||||
|
|
||||||
@@ -34,7 +30,7 @@ class TestUnit(unittest.TestCase):
|
|||||||
for i in range(50):
|
for i in range(50):
|
||||||
with open(self.testdir + '/unit.log', 'r') as f:
|
with open(self.testdir + '/unit.log', 'r') as f:
|
||||||
log = f.read()
|
log = f.read()
|
||||||
m = re.search('controller started', log, re.M | re.S)
|
m = re.search('controller started', log)
|
||||||
|
|
||||||
if m is None:
|
if m is None:
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
@@ -42,11 +38,12 @@ class TestUnit(unittest.TestCase):
|
|||||||
break
|
break
|
||||||
|
|
||||||
if m is None:
|
if m is None:
|
||||||
|
self._stop()
|
||||||
exit("Unit is writing log too long")
|
exit("Unit is writing log too long")
|
||||||
|
|
||||||
missed_module = ''
|
missed_module = ''
|
||||||
for module in modules:
|
for module in modules:
|
||||||
m = re.search('module: ' + module, log, re.M | re.S)
|
m = re.search('module: ' + module, log)
|
||||||
if m is None:
|
if m is None:
|
||||||
missed_module = module
|
missed_module = module
|
||||||
break
|
break
|
||||||
@@ -57,17 +54,6 @@ class TestUnit(unittest.TestCase):
|
|||||||
if missed_module:
|
if missed_module:
|
||||||
raise unittest.SkipTest('Unit has no ' + missed_module + ' module')
|
raise unittest.SkipTest('Unit has no ' + missed_module + ' module')
|
||||||
|
|
||||||
def check_version(self, version):
|
|
||||||
with open(self.pardir + '/src/nxt_main.h' , 'r') as f:
|
|
||||||
m = re.search('NXT_VERSION\s+"(\d+\.\d+)"', f.read(), re.M | re.S)
|
|
||||||
|
|
||||||
current = m.group(1).split('.')
|
|
||||||
need = version.split('.')
|
|
||||||
|
|
||||||
for i in range(len(need)):
|
|
||||||
if need[i] > current[i]:
|
|
||||||
raise unittest.SkipTest('Unit too old')
|
|
||||||
|
|
||||||
def _run(self):
|
def _run(self):
|
||||||
self.testdir = tempfile.mkdtemp(prefix='unit-test-')
|
self.testdir = tempfile.mkdtemp(prefix='unit-test-')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user