2019-12-04 21:06:29 +01:00
|
|
|
from tests.package.test_python import TestPythonPackageBase
|
|
|
|
|
|
|
|
|
|
|
|
class TestPythonDjango(TestPythonPackageBase):
|
|
|
|
config = TestPythonPackageBase.config
|
|
|
|
sample_scripts = ["tests/package/sample_python_django.py"]
|
|
|
|
|
|
|
|
def run_sample_scripts(self):
|
2020-04-11 16:57:50 +02:00
|
|
|
timeout = 35 * self.emulator.timeout_multiplier
|
|
|
|
|
2019-12-04 21:06:29 +01:00
|
|
|
cmd = "cd /opt && /usr/bin/django-admin startproject testsite"
|
2020-04-11 16:57:50 +02:00
|
|
|
self.assertRunOk(cmd, timeout=timeout)
|
2019-12-04 21:06:29 +01:00
|
|
|
|
|
|
|
cmd = "cd /opt/testsite && " + self.interpreter + " ./manage.py migrate"
|
2020-04-11 16:57:50 +02:00
|
|
|
output, exit_code = self.emulator.run(cmd, timeout=timeout)
|
2019-12-04 21:06:29 +01:00
|
|
|
self.assertIn("Operations to perform:", output[0])
|
|
|
|
self.assertEqual(exit_code, 0)
|
|
|
|
|
|
|
|
cmd = "cd /opt/testsite && " + self.interpreter + " ./manage.py runserver 0.0.0.0:1234 & "
|
|
|
|
# give some time to setup the server
|
2020-04-11 16:57:50 +02:00
|
|
|
cmd += "sleep {}".format(str(30 * self.emulator.timeout_multiplier))
|
|
|
|
self.assertRunOk(cmd, timeout=timeout)
|
2019-12-04 21:06:29 +01:00
|
|
|
|
|
|
|
cmd = "netstat -ltn 2>/dev/null | grep 0.0.0.0:1234"
|
|
|
|
self.assertRunOk(cmd)
|
|
|
|
|
2019-12-06 00:32:34 +01:00
|
|
|
|
2019-12-04 21:06:29 +01:00
|
|
|
class TestPythonPy3Django(TestPythonDjango):
|
|
|
|
__test__ = True
|
|
|
|
config = TestPythonDjango.config + \
|
|
|
|
"""
|
|
|
|
BR2_PACKAGE_PYTHON3=y
|
|
|
|
BR2_PACKAGE_PYTHON_DJANGO=y
|
|
|
|
BR2_PACKAGE_PYTHON3_SQLITE=y
|
|
|
|
"""
|