Skip to content

Commit 5457ef0

Browse files
committed
testing: fix up various aspects that are breaking tests (bug 1887042)
- skip: test_auth, test_dockerflow, test_notifications, test_diff_warnings - skip parts of test_landing_job - remove test_health module (mostly deprecated) - remove test_py3_code_quality (already replaced elsewhere) - convert headers in tests from a list to a dict (bug 1887043) - use django test client in lieu of FlaskClient (bug 1887043) - remove disable_migrations fixture - remove celery_app fixture - temporarily comment out cache decorators - adapt app fixture to new platform - remove flask celery functionality - add base celery support - add boilerplate django celery implementation - add db to github workflow (postgres) - add rust toolchain - various fix ups to get tests to run - various other missed fixes - various additions to the settings module - consolidate migrations
1 parent 222b7b1 commit 5457ef0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+362
-461
lines changed

.github/workflows/build.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@ on:
88
jobs:
99
run-tests:
1010
runs-on: ubuntu-latest
11+
services:
12+
postgres:
13+
image: postgres:latest
14+
env:
15+
POSTGRES_USER: postgres
16+
POSTGRES_PASSWORD: postgres
17+
ports:
18+
- 5432:5432
19+
options:
20+
--health-cmd pg_isready
21+
--health-interval 10s
22+
--health-timeout 5s
23+
--health-retries 5
1124
steps:
1225
- uses: actions/checkout@v4
1326
- name: Set up Python
@@ -22,7 +35,10 @@ jobs:
2235
python -m pip install -r requirements.txt
2336
python -m pip install -e .
2437
- name: Test
38+
env:
39+
DEFAULT_DB_HOST: 127.0.0.1
2540
run: |
2641
source env/bin/activate
42+
lando migrate
2743
lando test
28-
pytest
44+
pytest src/lando/api

Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,20 @@ EXPOSE 80
44
ENV PYTHONUNBUFFERED=1
55
ENV PYTHONDONTWRITEBYTECODE 1
66
RUN adduser --system --no-create-home app
7+
78
RUN mkdir /code
89
COPY ./ /code
910
RUN pip install --upgrade pip
11+
12+
13+
# Install the Rust toolchain. Some packages do not have pre-built wheels (e.g.
14+
# rs-parsepatch) and require this in order to compile.
15+
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
16+
17+
# Include ~/.cargo/bin in PATH.
18+
# See: rust-lang.org/tools/install (Configuring the PATH environment variable).
19+
ENV PATH="/root/.cargo/bin:${PATH}"
20+
1021
RUN pip install -r /code/requirements.txt
1122
RUN pip install -e /code
1223
USER app

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ build-backend = "setuptools.build_meta"
3232

3333
[tool.setuptools.packages.find]
3434
where = ["src"]
35+
36+
[tool.pytest.ini_options]
37+
DJANGO_SETTINGS_MODULE = "lando.settings"

requirements.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
black
22
jinja2
3+
kombu
34
pytest
45
pytest-django
6+
python-hglib==2.6.2
7+
python-jose
8+
redis
9+
requests-mock
510
ruff
611
uwsgi
12+
celery
13+
datadog
14+
rs-parsepatch
15+
networkx

src/lando/api/legacy/api/diff_warnings.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111

1212
import logging
1313

14-
from lando.main.support import problem
15-
1614
from lando.api.legacy.decorators import require_phabricator_api_key
1715
from lando.main.models.revision import DiffWarning, DiffWarningStatus
16+
from lando.main.support import problem
1817

1918
logger = logging.getLogger(__name__)
2019

src/lando/api/legacy/api/landing_jobs.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44
import logging
55

6-
from lando.main.support import ProblemException, g
7-
86
from lando.api import auth
97
from lando.main.models.landing_job import LandingJob, LandingJobAction, LandingJobStatus
8+
from lando.main.support import ProblemException, g
109

1110
logger = logging.getLogger(__name__)
1211

src/lando/api/legacy/api/stacks.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@
44
import logging
55
import urllib.parse
66

7-
from lando.main.support import problem
87
from lando import settings
9-
108
from lando.api.legacy.commit_message import format_commit_message
119
from lando.api.legacy.decorators import require_phabricator_api_key
12-
from lando.main.models.revision import Revision
1310
from lando.api.legacy.phabricator import PhabricatorClient
1411
from lando.api.legacy.projects import (
1512
get_release_managers,
@@ -42,6 +39,8 @@
4239
from lando.api.legacy.transplants import get_blocker_checks
4340
from lando.api.legacy.users import user_search
4441
from lando.api.legacy.validation import revision_id_to_int
42+
from lando.main.models.revision import Revision
43+
from lando.main.support import problem
4544

4645
logger = logging.getLogger(__name__)
4746

src/lando/api/legacy/api/transplants.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,11 @@
77
from typing import Optional
88

99
import kombu
10-
from lando.main.support import ProblemException, problem, g
11-
from lando import settings
1210

13-
from lando.api import auth
11+
from lando import settings
12+
from lando.api.legacy import auth
1413
from lando.api.legacy.commit_message import format_commit_message
1514
from lando.api.legacy.decorators import require_phabricator_api_key
16-
from lando.main.models.landing_job import (
17-
LandingJob,
18-
LandingJobStatus,
19-
add_revisions_to_job,
20-
)
21-
from lando.main.models.revision import Revision
2215
from lando.api.legacy.phabricator import PhabricatorClient
2316
from lando.api.legacy.projects import (
2417
CHECKIN_PROJ_SLUG,
@@ -67,6 +60,13 @@
6760
parse_landing_path,
6861
revision_id_to_int,
6962
)
63+
from lando.main.models.landing_job import (
64+
LandingJob,
65+
LandingJobStatus,
66+
add_revisions_to_job,
67+
)
68+
from lando.main.models.revision import Revision
69+
from lando.main.support import ProblemException, g, problem
7070

7171
logger = logging.getLogger(__name__)
7272

src/lando/api/legacy/api/try_push.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@
88
import io
99
import logging
1010

11-
from lando.main.support import ProblemException, g
12-
11+
from lando import settings
1312
from lando.api import auth
1413
from lando.api.legacy.hgexports import (
1514
GitPatchHelper,
1615
HgPatchHelper,
1716
PatchHelper,
1817
)
18+
from lando.api.legacy.repos import (
19+
get_repos_for_env,
20+
)
1921
from lando.main.models.landing_job import (
2022
LandingJobStatus,
2123
add_job_with_revisions,
2224
)
2325
from lando.main.models.revision import Revision
24-
from lando.api.legacy.repos import (
25-
get_repos_for_env,
26-
)
26+
from lando.main.support import ProblemException, g
2727

2828
logger = logging.getLogger(__name__)
2929

src/lando/api/legacy/api/uplift.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
import logging
66

7-
from lando.main.support import problem
87
from lando import settings
9-
108
from lando.api import auth
119
from lando.api.legacy.decorators import require_phabricator_api_key
1210
from lando.api.legacy.phabricator import PhabricatorClient
@@ -18,6 +16,7 @@
1816
get_uplift_repositories,
1917
)
2018
from lando.api.legacy.validation import revision_id_to_int
19+
from lando.main.support import problem
2120

2221
logger = logging.getLogger(__name__)
2322

0 commit comments

Comments
 (0)