diff mbox series

[2/2] support/testing/tests/package/test_python_django.py: New test

Message ID 20191015181356.5459-2-aduskett@gmail.com
State Superseded, archived
Headers show
Series None | expand

Commit Message

Adam Duskett Oct. 15, 2019, 6:13 p.m. UTC
From: Adam Duskett <Aduskett@gmail.com>

This test comprises of two simple steps:
  1: Start a new simple project called testsite.
  2: Run ./manage.py migrate on the new testsite.

Signed-off-by: Adam Duskett <Aduskett@gmail.com>
---
 .gitlab-ci.yml                                |  1 +
 .../tests/package/sample_python_django.py     |  1 +
 .../tests/package/test_python_django.py       | 26 +++++++++++++++++++
 3 files changed, 28 insertions(+)
 create mode 100644 support/testing/tests/package/sample_python_django.py
 create mode 100644 support/testing/tests/package/test_python_django.py

Comments

Ricardo Martincoski Oct. 15, 2019, 11:37 p.m. UTC | #1
Hello,

On Tue, Oct 15, 2019 at 03:13 PM, wrote:

> support/testing/tests/package/test_python_django.py: New test

The commit summary should be:
support/testing: add python-django test

> This test comprises of two simple steps:
>   1: Start a new simple project called testsite.
>   2: Run ./manage.py migrate on the new testsite.
> 
> Signed-off-by: Adam Duskett <Aduskett@gmail.com>

After changing the commit summary and fixing the warnings from flake8, and
changing or not the ';' to '&&' between the commands, you can add:
 Reviewed-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>

I tested both the original patch and with all suggestions to the test I make
below, so this tag is unconditional:
Tested-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>

> ---
>  .gitlab-ci.yml                                |  1 +
>  .../tests/package/sample_python_django.py     |  1 +
>  .../tests/package/test_python_django.py       | 26 +++++++++++++++++++
>  3 files changed, 28 insertions(+)
>  create mode 100644 support/testing/tests/package/sample_python_django.py

>  create mode 100644 support/testing/tests/package/test_python_django.py

Tip: if you add this file to your entry in the DEVELOPERS file you will be
notified if it ever fails.

[snip]
> +++ b/support/testing/tests/package/sample_python_django.py
> @@ -0,0 +1 @@
> +import django

In order to comply to flake8:
sample_python_django.py:1:1: F401 'django' imported but unused
use:
import django  # noqa: F401

> diff --git a/support/testing/tests/package/test_python_django.py b/support/testing/tests/package/test_python_django.py
> new file mode 100644
> index 0000000000..595134f50e
> --- /dev/null
> +++ b/support/testing/tests/package/test_python_django.py
> @@ -0,0 +1,26 @@
> +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):
> +        cmd = "cd /opt; /usr/bin/django-admin startproject testsite"

This ';' reminded me about a suggestion (a long time ago) from Thomas that is
still pending on my TODO list for another test... I will repeat it here:

        cmd = "cd /opt && /usr/bin/django-admin startproject testsite"

Maybe && between each command would be better?

> +        _, exit_code = self.emulator.run(cmd, timeout=30)
> +        self.assertEqual(exit_code, 0)
> +        cmd = "cd /opt/testsite; " + self.interpreter + " ./manage.py migrate"

The same here:
        cmd = "cd /opt/testsite && " + self.interpreter + " ./manage.py migrate"

> +        output, exit_code = self.emulator.run(cmd, timeout=30)
> +        self.assertIn("Operations to perform:", output[0])
> +        self.assertEqual(exit_code, 0)
> +

test_python_django.py:17:1: E302 expected 2 blank lines, found 1

> +class TestPythonPy3Django(TestPythonDjango):
> +    __test__ = True
> +    config = TestPythonDjango.config + \
> +        """
> +        BR2_PACKAGE_PYTHON3=y
> +        BR2_PACKAGE_PYTHON_DJANGO=y
> +        BR2_PACKAGE_PYTHON_SQLPARSE=y
> +        BR2_PACKAGE_PYTHON3_SQLITE=y
> +        """

> +

test_python_django.py:26:1: W391 blank line at end of file

> -- 
> 2.21.0

Regards,
Ricardo
diff mbox series

Patch

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 59efd51340..a840bcba0e 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -438,6 +438,7 @@  tests.package.test_python_constantly.TestPythonPy3Constantly: { extends: .runtim
 tests.package.test_python_crossbar.TestPythonPy3Crossbar: { extends: .runtime_test }
 tests.package.test_python_cryptography.TestPythonPy2Cryptography: { extends: .runtime_test }
 tests.package.test_python_cryptography.TestPythonPy3Cryptography: { extends: .runtime_test }
+tests.package.test_python_django.TestPythonPy3Django: { extends: .runtime_test }
 tests.package.test_python_incremental.TestPythonPy2Incremental: { extends: .runtime_test }
 tests.package.test_python_incremental.TestPythonPy3Incremental: { extends: .runtime_test }
 tests.package.test_python_passlib.TestPythonPy2Passlib: { extends: .runtime_test }
diff --git a/support/testing/tests/package/sample_python_django.py b/support/testing/tests/package/sample_python_django.py
new file mode 100644
index 0000000000..e7753d48fb
--- /dev/null
+++ b/support/testing/tests/package/sample_python_django.py
@@ -0,0 +1 @@ 
+import django
diff --git a/support/testing/tests/package/test_python_django.py b/support/testing/tests/package/test_python_django.py
new file mode 100644
index 0000000000..595134f50e
--- /dev/null
+++ b/support/testing/tests/package/test_python_django.py
@@ -0,0 +1,26 @@ 
+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):
+        cmd = "cd /opt; /usr/bin/django-admin startproject testsite"
+        _, exit_code = self.emulator.run(cmd, timeout=30)
+        self.assertEqual(exit_code, 0)
+        cmd = "cd /opt/testsite; " + self.interpreter + " ./manage.py migrate"
+        output, exit_code = self.emulator.run(cmd, timeout=30)
+        self.assertIn("Operations to perform:", output[0])
+        self.assertEqual(exit_code, 0)
+
+class TestPythonPy3Django(TestPythonDjango):
+    __test__ = True
+    config = TestPythonDjango.config + \
+        """
+        BR2_PACKAGE_PYTHON3=y
+        BR2_PACKAGE_PYTHON_DJANGO=y
+        BR2_PACKAGE_PYTHON_SQLPARSE=y
+        BR2_PACKAGE_PYTHON3_SQLITE=y
+        """
+