test_python_django.py 1.1 KB

1234567891011121314151617181920212223242526272829303132
  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. cmd = "cd /opt && /usr/bin/django-admin startproject testsite"
  7. self.assertRunOk(cmd, timeout=30)
  8. cmd = "cd /opt/testsite && " + self.interpreter + " ./manage.py migrate"
  9. output, exit_code = self.emulator.run(cmd, timeout=30)
  10. self.assertIn("Operations to perform:", output[0])
  11. self.assertEqual(exit_code, 0)
  12. cmd = "cd /opt/testsite && " + self.interpreter + " ./manage.py runserver 0.0.0.0:1234 & "
  13. # give some time to setup the server
  14. cmd += "sleep 30"
  15. self.assertRunOk(cmd, timeout=35)
  16. cmd = "netstat -ltn 2>/dev/null | grep 0.0.0.0:1234"
  17. self.assertRunOk(cmd)
  18. class TestPythonPy3Django(TestPythonDjango):
  19. __test__ = True
  20. config = TestPythonDjango.config + \
  21. """
  22. BR2_PACKAGE_PYTHON3=y
  23. BR2_PACKAGE_PYTHON_DJANGO=y
  24. BR2_PACKAGE_PYTHON3_SQLITE=y
  25. """