Skip to content

Commit

Permalink
tests: fix settings (bug 1894467) (#51)
Browse files Browse the repository at this point in the history
- modify settings import to django.conf throughout project
- add test_settings module
- point pytest to new test_settings module
  • Loading branch information
zzzeid authored May 1, 2024
1 parent acee5db commit 8daf480
Show file tree
Hide file tree
Showing 23 changed files with 37 additions and 22 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ build-backend = "setuptools.build_meta"
where = ["src"]

[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE = "lando.settings"
DJANGO_SETTINGS_MODULE = "lando.test_settings"
2 changes: 1 addition & 1 deletion src/lando/api/legacy/api/stacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging
import urllib.parse

from lando import settings
from django.conf import settings
from lando.api.legacy.commit_message import format_commit_message
from lando.api.legacy.decorators import require_phabricator_api_key
from lando.api.legacy.phabricator import PhabricatorClient
Expand Down
2 changes: 1 addition & 1 deletion src/lando/api/legacy/api/transplants.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import kombu

from lando import settings
from django.conf import settings
from lando.api.legacy import auth
from lando.api.legacy.commit_message import format_commit_message
from lando.api.legacy.decorators import require_phabricator_api_key
Expand Down
2 changes: 1 addition & 1 deletion src/lando/api/legacy/api/try_push.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import io
import logging

from lando import settings
from django.conf import settings
from lando.api import auth
from lando.api.legacy.hgexports import (
GitPatchHelper,
Expand Down
2 changes: 1 addition & 1 deletion src/lando/api/legacy/api/uplift.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import logging

from lando import settings
from django.conf import settings
from lando.api import auth
from lando.api.legacy.decorators import require_phabricator_api_key
from lando.api.legacy.phabricator import PhabricatorClient
Expand Down
2 changes: 1 addition & 1 deletion src/lando/api/legacy/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from django.core.cache import cache
from jose import jwt

from lando import settings
from django.conf import settings
from lando.api.legacy.mocks.auth import MockAuth0
from lando.api.legacy.repos import AccessGroup
from lando.api.legacy.systems import Subsystem
Expand Down
2 changes: 1 addition & 1 deletion src/lando/api/legacy/bmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import requests

from lando import settings
from django.conf import settings


def bmo_uplift_endpoint() -> str:
Expand Down
2 changes: 1 addition & 1 deletion src/lando/api/legacy/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from flask_caching.backends.rediscache import RedisCache
from redis import RedisError

from lando import settings
from django.conf import settings
from lando.api.legacy.redis import SuppressRedisFailure
from lando.api.legacy.systems import Subsystem

Expand Down
2 changes: 1 addition & 1 deletion src/lando/api/legacy/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Callable,
)

from lando import settings
from django.conf import settings
from lando.api.legacy.phabricator import PhabricatorClient
from lando.main.support import problem, request

Expand Down
2 changes: 1 addition & 1 deletion src/lando/api/legacy/phabricator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import requests

from lando import settings
from django.conf import settings
from lando.api.legacy.systems import Subsystem

logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion src/lando/api/legacy/repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
)
from typing import Optional

from lando import settings
from django.conf import settings
from lando.api.legacy.systems import Subsystem

logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion src/lando/api/legacy/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration

from lando import settings
from django.conf import settings
from lando.api.legacy.systems import Subsystem

logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion src/lando/api/legacy/smtp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import smtplib
from contextlib import contextmanager

from lando import settings
from django.conf import settings
from lando.api.legacy.systems import Subsystem

logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion src/lando/api/legacy/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import ssl
from typing import Optional

from lando import settings
from django.conf import settings
from lando.api.legacy.celery import celery
from lando.api.legacy.email import make_failure_email
from lando.api.legacy.phabricator import (
Expand Down
2 changes: 1 addition & 1 deletion src/lando/api/legacy/transplants.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import requests

from lando import settings
from django.conf import settings
from lando.api.legacy.phabricator import (
PhabricatorClient,
PhabricatorRevisionStatus,
Expand Down
2 changes: 1 addition & 1 deletion src/lando/api/legacy/treestatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import requests

from lando import settings
from django.conf import settings
from lando.api.legacy.systems import Subsystem

logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion src/lando/api/legacy/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import logging
from urllib.parse import urlparse

from lando import settings
from django.conf import settings
from lando.api.legacy.systems import Subsystem

logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion src/lando/api/legacy/uplift.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
Version,
)

from lando import settings
from django.conf import settings
from lando.api.legacy import bmo
from lando.api.legacy.phabricator import PhabricatorClient
from lando.api.legacy.phabricator_patch import patch_to_changes
Expand Down
2 changes: 1 addition & 1 deletion src/lando/api/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from django.http import JsonResponse as JSONResponse
from django.test import Client

from lando import settings
from django.conf import settings
from lando.api.legacy.mocks.auth import TEST_JWKS, MockAuth0
from lando.api.legacy.phabricator import PhabricatorClient
from lando.api.legacy.projects import (
Expand Down
2 changes: 1 addition & 1 deletion src/lando/jinja.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.utils.html import escape

from jinja2 import Environment
from lando import settings
from django.conf import settings
from lando.ui.legacy.forms import UserSettingsForm

import datetime
Expand Down
2 changes: 1 addition & 1 deletion src/lando/main/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from django.db import models
from django.db import connection

from lando import settings
from django.conf import settings
from lando.utils import GitPatchHelper

logger = logging.getLogger(__name__)
Expand Down
1 change: 0 additions & 1 deletion src/lando/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@
OIDC_OP_AUTHORIZATION_ENDPOINT = f"{OIDC_DOMAIN}/authorize"
OIDC_REDIRECT_REQUIRE_HTTPS = True

OIDC_DOMAIN = os.getenv("OIDC_DOMAIN")
OIDC_RP_CLIENT_ID = os.getenv("OIDC_RP_CLIENT_ID")
OIDC_RP_CLIENT_SECRET = os.getenv("OIDC_RP_CLIENT_SECRET")

Expand Down
16 changes: 16 additions & 0 deletions src/lando/test_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from lando.settings import *


OIDC_DOMAIN = "lando-api.auth0.test"
OIDC_OP_TOKEN_ENDPOINT = f"{OIDC_DOMAIN}/oauth/token"
OIDC_OP_USER_ENDPOINT = f"{OIDC_DOMAIN}/userinfo"
OIDC_OP_AUTHORIZATION_ENDPOINT = f"{OIDC_DOMAIN}/authorize"
OIDC_REDIRECT_REQUIRE_HTTPS = True

OIDC_IDENTIFIER = "lando-api" # Added for compatibility with tests, should not be needed.
GITHUB_ACCESS_TOKEN = ""
PHABRICATOR_URL = "http://phabricator.test"
PHABRICATOR_ADMIN_API_KEY = "api-thiskeymustbe32characterslen"
PHABRICATOR_UNPRIVILEGED_API_KEY = "api-thiskeymustbe32characterslen"
CELERY_TASK_ALWAYS_EAGER = True
ENVIRONMENT = "test"

0 comments on commit 8daf480

Please sign in to comment.