Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
domdinicola committed Dec 30, 2024
1 parent 6c45af4 commit c6bb351
Show file tree
Hide file tree
Showing 22 changed files with 100 additions and 99 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,28 @@ jobs:
ci:
runs-on: ubuntu-latest
name: Test py${{ matrix.python-version }}/dj${{matrix.django-version}}

services:
db:
image: postgres
env:
POSTGRES_PASSWORD: pass
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
defaults:
run:
shell: bash
Expand Down Expand Up @@ -91,6 +113,9 @@ jobs:
if: needs.changes.outputs.run_tests
run: |
uv run pytest --create-db --junit-xml junit-${{ matrix.python-version }}-${{matrix.django-version}}.xml
env:
SECRET_KEY: "test-key"
DATABASE_URL: "psql://postgres:pass@localhost:5432/postgres"

- name: Upload pytest test results
uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ dev-dependencies = [
"pytest",
"pytest-coverage",
"pytest-django",
"pytest-echo",
"pytest-echo>=1.7.3",
"pytest-ignore-flaky",
"pytest-pythonpath",
"responses",
Expand Down
19 changes: 19 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[pytest]
norecursedirs = data
pythonpath = . src tests
DJANGO_SETTINGS_MODULE = donor_reporting_portal.config.settings
django_find_project = false
addopts =
-v
--reuse-db
--tb=short
--maxfail=20
--echo-version=donor_reporting_portal
--echo-version=django
--capture=no
--cov-report=html
--cov-config=tests/.coveragerc
--cov=donor_reporting_portal

markers =
slow: marks tests as slow (deselect with '-m "not slow"')
Empty file removed tests/__init__.py
Empty file.
26 changes: 26 additions & 0 deletions tests/_api_checker/api_checker/get_user.fixture.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"get_user": {
"master": {
"model": "core.user",
"pk": 26,
"fields": {
"password": "",
"last_login": null,
"is_superuser": true,
"username": "user999",
"first_name": "Suzanne",
"last_name": "Ferguson",
"email": "[email protected]",
"is_staff": false,
"is_active": true,
"date_joined": "2024-12-30T17:25:26.555Z",
"azure_id": null,
"job_title": null,
"display_name": "Suzanne Ferguson:",
"groups": [],
"user_permissions": []
}
},
"deps": []
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"Vary": "Accept, Origin, Cookie",
"Allow": "GET",
"X-Frame-Options": "DENY",
"Content-Length": "256",
"Content-Length": "272",
"X-Content-Type-Options": "nosniff",
"Referrer-Policy": "same-origin",
"Cross-Origin-Opener-Policy": "same-origin"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"Cross-Origin-Opener-Policy": "same-origin"
},
"data": {
"id": 135,
"id": 26,
"username": "user999",
"first_name": "Jennifer",
"last_name": "Garcia",
Expand All @@ -37,4 +37,4 @@
"roles": []
},
"content_type": "application/json"
}
}
2 changes: 1 addition & 1 deletion tests/api/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest
from drf_api_checker.pytest import contract

from tests.api_checker import LastModifiedRecorder
from api_checker import LastModifiedRecorder


@pytest.mark.django_db
Expand Down
6 changes: 3 additions & 3 deletions tests/api/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

from drf_api_checker.pytest import contract, frozenfixture

from tests.api_checker import ExpectedErrorRecorder, LastModifiedRecorder
from tests.factories import (
from api_checker import ExpectedErrorRecorder, LastModifiedRecorder
from factories import (
DonorFactory,
DRPMetadataFactory,
ExternalGrantFactory,
GrantFactory,
ThemeFactory,
UserRoleFactory,
)
from tests.perms import user_grant_permissions, user_grant_role_permission
from perms import user_grant_permissions, user_grant_role_permission


@frozenfixture()
Expand Down
4 changes: 2 additions & 2 deletions tests/api/test_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import pytest
from drf_api_checker.pytest import contract, frozenfixture

from tests.api_checker import LastModifiedRecorder
from tests.factories import BusinessAreaFactory, UserFactory, UserRoleFactory
from api_checker import LastModifiedRecorder
from factories import BusinessAreaFactory, UserFactory, UserRoleFactory


@frozenfixture()
Expand Down
8 changes: 4 additions & 4 deletions tests/api/test_sharepoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
from drf_api_checker.pytest import api_checker_datadir, contract, frozenfixture # noqa
from drf_api_checker.recorder import Recorder

from tests.api_checker import LastModifiedRecorder
from tests.factories import (
from api_checker import LastModifiedRecorder
from factories import (
DonorFactory,
SharePointGroupFactory,
SharePointLibraryFactory,
SharePointSiteFactory,
SharePointTenantFactory,
)
from tests.perms import user_grant_role_permission
from tests.vcrpy import VCR
from perms import user_grant_role_permission
from vcrpy import VCR


@frozenfixture()
Expand Down
2 changes: 1 addition & 1 deletion tests/api_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from rest_framework.response import Response
from rest_framework.test import APIClient

from tests.factories import UserFactory
from factories import UserFactory


def frozenfixture(fixture_name=default_fixture_name, is_fixture=True):
Expand Down
2 changes: 1 addition & 1 deletion tests/apps/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from tests.perms import user_grant_role_permission
from perms import user_grant_role_permission


@pytest.mark.django_db
Expand Down
2 changes: 1 addition & 1 deletion tests/apps/test_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.urls import reverse

from donor_reporting_portal.apps.roles.models import UserRole
from tests.factories import GroupFactory, UserRoleFactory
from factories import GroupFactory, UserRoleFactory


def test_admin_userrole(django_app, admin_user, userrole, donor, group, secondary_donor):
Expand Down
2 changes: 1 addition & 1 deletion tests/apps/test_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from tests.factories import GroupFactory
from factories import GroupFactory


@pytest.mark.django_db
Expand Down
2 changes: 1 addition & 1 deletion tests/apps/test_synchronizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from donor_reporting_portal.apps.report_metadata.models import Donor, ExternalGrant, Grant
from donor_reporting_portal.apps.report_metadata.synchronizers import GrantSynchronizer
from tests.vcrpy import VCR
from vcrpy import VCR


@pytest.mark.django_db
Expand Down
2 changes: 1 addition & 1 deletion tests/apps/vcr_cassettes/test_grant_sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interactions:
User-Agent:
- python-requests/2.22.0
method: GET
uri: https://uniapis.unicef.org/biapi/v1/dsgrants
uri: http://invalid_vision_url/dsgrants
response:
body:
string: "{\"ROWSET\":{\"ROW\":[{\"GRANT_REF\":\"ABV\",\"DESCRIPTION\":\"\
Expand Down
7 changes: 4 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pytest
from rest_framework.test import APIClient

from .factories import (
from factories import (
BusinessAreaFactory,
DonorFactory,
ExternalGrantFactory,
Expand All @@ -21,15 +21,16 @@


def pytest_configure(config):
# enable this to remove deprecations
os.environ["SECRET_KEY"] = "6311bc92d3d1ebf12ae2aa54d8aaeeafa9e8cdb4"
os.environ["CELERY_TASK_ALWAYS_EAGER"] = "1"
os.environ["STATIC_ROOT"] = tempfile.gettempdir()


@pytest.fixture(autouse=True)
def use_override_settings(settings):
settings.SECRET_KEY = "6311bc92d3d1ebf12ae2aa54d8aaeeafa9e8cdb4"
os.environ["SECRET_KEY"] = "6311bc92d3d1ebf12ae2aa54d8aaeeafa9e8cdb4"
os.environ["CELERY_TASK_ALWAYS_EAGER"] = "1"
os.environ["STATIC_ROOT"] = tempfile.gettempdir()


@pytest.fixture(scope="session")
Expand Down
2 changes: 1 addition & 1 deletion tests/factories/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from donor_reporting_portal.apps.core.models import User
from donor_reporting_portal.apps.roles.models import UserRole
from tests.factories import DonorFactory
from factories import DonorFactory


class GroupFactory(factory.django.DjangoModelFactory):
Expand Down
2 changes: 1 addition & 1 deletion tests/perms.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from donor_reporting_portal.apps.roles.models import UserRole

from .factories import GroupFactory
from factories import GroupFactory

whitespace = " \t\n\r\v\f"
lowercase = "abcdefghijklmnopqrstuvwxyz"
Expand Down
70 changes: 0 additions & 70 deletions tox.ini

This file was deleted.

8 changes: 4 additions & 4 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c6bb351

Please sign in to comment.