From 605b2dfa437a51278f9cb7ba89594a43043bd499 Mon Sep 17 00:00:00 2001 From: Paul Prescod Date: Fri, 3 Jan 2020 20:06:56 -0800 Subject: [PATCH 01/13] Test review apps. --- app.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app.json b/app.json index 125d9c91..309eb1d6 100644 --- a/app.json +++ b/app.json @@ -126,6 +126,16 @@ "env": { "DJANGO_SETTINGS_MODULE": "config.settings.test" } + }, + "review": { + "scripts": { + "test-setup": "pip install --upgrade -r requirements/test.txt", + "test": "pytest" + }, + "addons": ["heroku-postgresql:in-dyno", "heroku-redis:in-dyno"], + "env": { + "DJANGO_SETTINGS_MODULE": "config.settings.integration_tests" + } } } } From 140ba229043066247f25c9fdbbb812636e8c374c Mon Sep 17 00:00:00 2001 From: Paul Prescod Date: Fri, 3 Jan 2020 20:49:56 -0800 Subject: [PATCH 02/13] Another attempt at review apps --- app.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app.json b/app.json index 309eb1d6..a4b4b4a1 100644 --- a/app.json +++ b/app.json @@ -135,7 +135,8 @@ "addons": ["heroku-postgresql:in-dyno", "heroku-redis:in-dyno"], "env": { "DJANGO_SETTINGS_MODULE": "config.settings.integration_tests" - } + }, + "space": "sfdoc" } } } From 47ee5fc968e937c8dddcb1dd642c8d5d757f4c15 Mon Sep 17 00:00:00 2001 From: Paul Prescod Date: Sat, 4 Jan 2020 09:51:49 -0800 Subject: [PATCH 03/13] Attempt to fix dyno type. --- app.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app.json b/app.json index a4b4b4a1..5b23ec55 100644 --- a/app.json +++ b/app.json @@ -106,11 +106,11 @@ "formation": { "web": { "quantity": 1, - "size": "free" + "size": "Private-S" }, "worker": { "quantity": 1, - "size": "free" + "size": "Private-S" } }, "scripts": { From 6c2d6841714060d94933cd1a26e96926317fb1e0 Mon Sep 17 00:00:00 2001 From: Paul Prescod Date: Sat, 4 Jan 2020 11:09:50 -0800 Subject: [PATCH 04/13] Next step with review apps --- Procfile | 2 +- utility/heroku-release.py | 11 +++++++++++ utility/heroku-release.sh | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 utility/heroku-release.py create mode 100644 utility/heroku-release.sh diff --git a/Procfile b/Procfile index 20b99401..5d5d9b7e 100644 --- a/Procfile +++ b/Procfile @@ -1,3 +1,3 @@ -release: python manage.py migrate --noinput +release: utility/heroku-release.sh web: gunicorn config.wsgi:application worker: python manage.py rqworker default diff --git a/utility/heroku-release.py b/utility/heroku-release.py new file mode 100644 index 00000000..e23d981c --- /dev/null +++ b/utility/heroku-release.py @@ -0,0 +1,11 @@ +import os + +if os.environ.get(HEROKU_APP_NAME, "").startswith("sfdoc-review-apps-"): + os.system("pip install --upgrade -r test/requirements.txt") + os.system("pytest") + +# Todo: + +# check for HEROKU_APP_NAME . startswith(sfdoc-review-apps-) +# then run `pip install --upgrade test/requirements.txt` +# then run pytest with all of the environment variables diff --git a/utility/heroku-release.sh b/utility/heroku-release.sh new file mode 100644 index 00000000..8a6a377d --- /dev/null +++ b/utility/heroku-release.sh @@ -0,0 +1,2 @@ +python manage.py migrate --noinput +python heroku-release.py \ No newline at end of file From 45c6be869cbd4363e1fcc4969e2c443cbb56c5a7 Mon Sep 17 00:00:00 2001 From: Paul Prescod Date: Sat, 4 Jan 2020 11:10:54 -0800 Subject: [PATCH 05/13] Fix typo --- utility/heroku-release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utility/heroku-release.sh b/utility/heroku-release.sh index 8a6a377d..694cc2bd 100644 --- a/utility/heroku-release.sh +++ b/utility/heroku-release.sh @@ -1,2 +1,2 @@ python manage.py migrate --noinput -python heroku-release.py \ No newline at end of file +python utility/heroku-release.py \ No newline at end of file From e5dacafbcd5fca233ca1bf66c5c20e3c006e4fc1 Mon Sep 17 00:00:00 2001 From: Paul Prescod Date: Sat, 4 Jan 2020 11:22:49 -0800 Subject: [PATCH 06/13] Permissions --- utility/heroku-release.py | 0 utility/heroku-release.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 utility/heroku-release.py mode change 100644 => 100755 utility/heroku-release.sh diff --git a/utility/heroku-release.py b/utility/heroku-release.py old mode 100644 new mode 100755 diff --git a/utility/heroku-release.sh b/utility/heroku-release.sh old mode 100644 new mode 100755 From 27968670dc41e0f42b4aba554f46a6c8b63fff55 Mon Sep 17 00:00:00 2001 From: Paul Prescod Date: Sat, 4 Jan 2020 20:05:06 -0800 Subject: [PATCH 07/13] Updates to environment variables etc. --- utility/heroku-release.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/utility/heroku-release.py b/utility/heroku-release.py index e23d981c..f9515186 100755 --- a/utility/heroku-release.py +++ b/utility/heroku-release.py @@ -1,11 +1,6 @@ import os -if os.environ.get(HEROKU_APP_NAME, "").startswith("sfdoc-review-apps-"): - os.system("pip install --upgrade -r test/requirements.txt") - os.system("pytest") - -# Todo: - -# check for HEROKU_APP_NAME . startswith(sfdoc-review-apps-) -# then run `pip install --upgrade test/requirements.txt` -# then run pytest with all of the environment variables +if os.environ.get("HEROKU_APP_NAME", "").startswith("sfdoc-review-apps-"): + assert not os.system("pip install --upgrade -r test/requirements.txt") + os.environ["DJANGO_SETTINGS_MODULE"] = "config.settings.integration_tests" + assert not os.system("pytest") From a14b17fff160c10d6270c630d6f65fc99ba0bf61 Mon Sep 17 00:00:00 2001 From: Paul Prescod Date: Sat, 4 Jan 2020 20:14:27 -0800 Subject: [PATCH 08/13] Point to correct requirements.txt file. --- utility/heroku-release.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utility/heroku-release.py b/utility/heroku-release.py index f9515186..9f154f44 100755 --- a/utility/heroku-release.py +++ b/utility/heroku-release.py @@ -1,6 +1,6 @@ import os if os.environ.get("HEROKU_APP_NAME", "").startswith("sfdoc-review-apps-"): - assert not os.system("pip install --upgrade -r test/requirements.txt") + assert not os.system("pip install --upgrade -r requirements/test.txt") os.environ["DJANGO_SETTINGS_MODULE"] = "config.settings.integration_tests" assert not os.system("pytest") From 06537679c114774214fa50b12be70ab84a6c797c Mon Sep 17 00:00:00 2001 From: Paul Prescod Date: Sat, 4 Jan 2020 20:24:34 -0800 Subject: [PATCH 09/13] Remove reference to debug_toolbar --- config/settings/integration_tests.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/config/settings/integration_tests.py b/config/settings/integration_tests.py index cc836e69..f4e875f2 100644 --- a/config/settings/integration_tests.py +++ b/config/settings/integration_tests.py @@ -34,11 +34,6 @@ } } -# django-debug-toolbar -# ------------------------------------------------------------------------------ -MIDDLEWARE += ["debug_toolbar.middleware.DebugToolbarMiddleware"] -INSTALLED_APPS += ["debug_toolbar"] - INTERNAL_IPS = ["127.0.0.1", "10.0.2.2"] DEBUG_TOOLBAR_CONFIG = { @@ -81,6 +76,8 @@ SALESFORCE_JWT_PRIVATE_KEY = process_key(env("SALESFORCE_JWT_PRIVATE_KEY")) SALESFORCE_SANDBOX = env.bool("SALESFORCE_SANDBOX") SALESFORCE_USERNAME = env("SALESFORCE_USERNAME") +SALESFORCE_ARTICLE_LINK_LIMIT = 100 + # django-rq REDIS_URL = env("REDIS_URL", default="redis://localhost:6379") @@ -99,5 +96,6 @@ # easyDITA EASYDITA_INSTANCE_URL = env("EASYDITA_INSTANCE_URL") -EASYDITA_USERNAME = env("EASYDITA_USERNAME") +# One of our test cases changed in EasyDITA and needs to be fixed back. +EASYDITA_USERNAME = "mock" # env("EASYDITA_USERNAME") EASYDITA_PASSWORD = env("EASYDITA_PASSWORD") \ No newline at end of file From 996984ba49d4884cecfda3858ac0992360555401 Mon Sep 17 00:00:00 2001 From: Paul Prescod Date: Sat, 4 Jan 2020 20:30:17 -0800 Subject: [PATCH 10/13] Remove django-extensions dependency --- config/settings/integration_tests.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config/settings/integration_tests.py b/config/settings/integration_tests.py index f4e875f2..00d18540 100644 --- a/config/settings/integration_tests.py +++ b/config/settings/integration_tests.py @@ -41,10 +41,6 @@ "SHOW_TEMPLATE_CONTEXT": True, } -# django-extensions -# ------------------------------------------------------------------------------ -INSTALLED_APPS += ["django_extensions"] - # TESTING # ------------------------------------------------------------------------------ TEST_RUNNER = "django.test.runner.DiscoverRunner" From 13020e2f4faeb4336095b13a687c673ff7a7c951 Mon Sep 17 00:00:00 2001 From: Paul Prescod Date: Sat, 4 Jan 2020 20:42:37 -0800 Subject: [PATCH 11/13] Try to get pytest to use provided Postgres --- sfdoc/conftest.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 sfdoc/conftest.py diff --git a/sfdoc/conftest.py b/sfdoc/conftest.py new file mode 100644 index 00000000..005bda74 --- /dev/null +++ b/sfdoc/conftest.py @@ -0,0 +1,9 @@ +import os +import pytest +import environ + +if os.environ.get("HEROKU_APP_NAME", "").startswith("sfdoc-review-apps-"): + env = environ.Env() + @pytest.fixture(scope='session') + def django_db_setup(): + settings.DATABASES['default'] = env.db("DATABASE_URL") From 91274964691ee12c6e364859a1c2806096ccaabe Mon Sep 17 00:00:00 2001 From: Paul Prescod Date: Sat, 4 Jan 2020 20:53:25 -0800 Subject: [PATCH 12/13] Add missnig import --- sfdoc/conftest.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sfdoc/conftest.py b/sfdoc/conftest.py index 005bda74..371e10d6 100644 --- a/sfdoc/conftest.py +++ b/sfdoc/conftest.py @@ -1,6 +1,7 @@ import os import pytest import environ +from django.conf import settings if os.environ.get("HEROKU_APP_NAME", "").startswith("sfdoc-review-apps-"): env = environ.Env() From 231b1ff11b064be3e15aa9acc40a312f0bcf0529 Mon Sep 17 00:00:00 2001 From: Paul Prescod Date: Mon, 6 Jan 2020 09:29:51 -0800 Subject: [PATCH 13/13] Add documentation about conftest. --- sfdoc/conftest.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sfdoc/conftest.py b/sfdoc/conftest.py index 371e10d6..e3322623 100644 --- a/sfdoc/conftest.py +++ b/sfdoc/conftest.py @@ -3,6 +3,12 @@ import environ from django.conf import settings +# this recipe convinces pytest-sjango to use the pre-existing +# database instead of creating a new one. Heroku apps seem +# to not have permissions to create databases on the fly. + +# https://pytest-django.readthedocs.io/en/latest/database.html#using-an-existing-external-database-for-tests + if os.environ.get("HEROKU_APP_NAME", "").startswith("sfdoc-review-apps-"): env = environ.Env() @pytest.fixture(scope='session')