2
1

test_python_django.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. from tests.package.test_python import TestPythonPackageBase
  2. class TestPythonDjango(TestPythonPackageBase):
  3. config = TestPythonPackageBase.config
  4. sample_scripts = ["tests/package/sample_python_django.py"]
  5. def run_sample_scripts(self):
  6. timeout = 35 * self.emulator.timeout_multiplier
  7. cmd = "cd /opt && /usr/bin/django-admin startproject testsite"
  8. self.assertRunOk(cmd, timeout=timeout)
  9. cmd = "cd /opt/testsite && " + self.interpreter + " ./manage.py migrate"
  10. output, exit_code = self.emulator.run(cmd, timeout=timeout)
  11. self.assertIn("Operations to perform:", output[0])
  12. self.assertEqual(exit_code, 0)
  13. cmd = "cd /opt/testsite && " + self.interpreter + " ./manage.py runserver 0.0.0.0:1234 & "
  14. # give some time to setup the server
  15. cmd += "sleep {}".format(str(30 * self.emulator.timeout_multiplier))
  16. self.assertRunOk(cmd, timeout=timeout)
  17. cmd = "netstat -ltn 2>/dev/null | grep 0.0.0.0:1234"
  18. self.assertRunOk(cmd)
  19. class TestPythonPy3Django(TestPythonDjango):
  20. __test__ = True
  21. config = TestPythonDjango.config + \
  22. """
  23. BR2_PACKAGE_PYTHON3=y
  24. BR2_PACKAGE_PYTHON_DJANGO=y
  25. BR2_PACKAGE_PYTHON3_SQLITE=y
  26. """