Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tox integration tests #21

Merged
merged 4 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignore:
- "wireup.integration"
13 changes: 2 additions & 11 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
name: Test Coverage

on: [push, pull_request]

on: [push]
jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Create venv
run: python -m venv .venv

- name: Install dependencies
run: make install

- name: Run tests
run: .venv/bin/coverage run -m unittest discover -s test

run: .venv/bin/coverage run -m unittest discover -s test/unit
- name: Generate coverage report
run: |
.venv/bin/coverage xml

- name: Upload coverage to CodeClimate
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TOKEN }}
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/run_all.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
name: Python package

name: Run tests
on: [push]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/run_integration_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Integration tests
on: [push]
jobs:
test:
name: Run Tox
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Create venv
run: python -m venv .venv
- name: Install dependencies
run: |
make install
- name: Run tox
run: .venv/bin/tox
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ check-mypy:
.venv/bin/mypy wireup --strict

test:
.venv/bin/python -m unittest discover -s test/
.venv/bin/python -m unittest discover -s test/unit

profile ./profile_tests $(num_runs):
./.venv/bin/python ./profile_tests.py $(num_runs)
Expand Down
400 changes: 102 additions & 298 deletions poetry.lock

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,8 @@ mkdocs-open-in-new-tab = "^1.0.2"
mike = "^1.1.2"
typing-extensions = "^4.7.1"
mypy = "1.9.0"
flask = "^3.0.0"
coverage = "^7.3.2"
fastapi = "^0.105.0"
httpx = "^0.26.0"
tox = "^4.14.2"

[tool.ruff]
target-version = "py38"
Expand Down Expand Up @@ -106,3 +104,6 @@ exclude_also = [
"class .*\\bProtocol\\):",
"@(abc\\.)?abstractmethod",
]

[tool.mypy]
exclude = "wireup.integration"
2 changes: 1 addition & 1 deletion test/integration/test_fastapi_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from fastapi.testclient import TestClient
from typing_extensions import Annotated

from test.services.no_annotations.random.random_service import RandomService
from test.unit.services.no_annotations.random.random_service import RandomService
from wireup import Wire, ParameterBag, DependencyContainer
from wireup.errors import UnknownServiceRequestedError
from wireup.integration.fastapi_integration import wireup_init_fastapi_integration
Expand Down
3 changes: 2 additions & 1 deletion test/integration/test_flask_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
from dataclasses import dataclass

from test.fixtures import FooBar, FooBase
from test.services.no_annotations.random.random_service import RandomService

from flask import Flask
from typing_extensions import Annotated

from test.unit.services.no_annotations.random.random_service import RandomService
from wireup import DependencyContainer, ParameterBag, Wire
from wireup.integration.flask_integration import wireup_init_flask_integration

Expand Down
1 change: 0 additions & 1 deletion test/services/no_annotations/foo/__init__.py

This file was deleted.

File renamed without changes.
1 change: 1 addition & 0 deletions test/unit/services/no_annotations/foo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from test.unit.services.no_annotations.foo.baz_service import BazService
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from test.services.no_annotations.db_service import DbService
from test.services.no_annotations.foo.foo_service import FooService
from test.unit.services.no_annotations.db_service import DbService
from test.unit.services.no_annotations.foo.foo_service import FooService


class BazService:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from dataclasses import dataclass
from test.services.no_annotations.db_service import DbService

from test.unit.services.no_annotations.db_service import DbService


@dataclass
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from test.services.no_annotations.random.random_service import RandomService
from test.unit.services.no_annotations.random.random_service import RandomService


class TrulyRandomService:
Expand Down
Empty file.
7 changes: 4 additions & 3 deletions test/test_container.py → test/unit/test_container.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import datetime
import unittest
from dataclasses import dataclass
from test import services
from test.fixtures import Counter, FooBar, FooBase, FooBaz
from test.services.no_annotations.random.random_service import RandomService
from test.services.no_annotations.random.truly_random_service import TrulyRandomService
from unittest.mock import Mock, patch

from typing_extensions import Annotated

from test.unit import services
from test.unit.services.no_annotations.random.random_service import RandomService
from test.unit.services.no_annotations.random.truly_random_service import TrulyRandomService
from wireup import ServiceLifetime, Wire, register_all_in_module, wire
from wireup.errors import (
DuplicateQualifierForInterfaceError,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import unittest
from dataclasses import dataclass
from test.fixtures import FooBar, FooBase, FooBaz
from test.services.no_annotations.random.random_service import RandomService

from typing_extensions import Annotated

from test.unit.services.no_annotations.random.random_service import RandomService
from wireup import DependencyContainer, ParameterBag, ServiceLifetime, Wire


Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import unittest

from test.fixtures import FooBase, FooBar
from test.services.no_annotations.random.random_service import RandomService
from unittest.mock import MagicMock, patch

from typing_extensions import Annotated

from test.unit.services.no_annotations.random.random_service import RandomService
from wireup import DependencyContainer, ParameterBag, Wire
from wireup.ioc.override_manager import OverrideManager
from wireup.ioc.types import ServiceOverride
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest
from test.services.no_annotations.random.random_service import RandomService
from test.services.no_annotations.random.truly_random_service import TrulyRandomService

from test.unit.services.no_annotations.random.random_service import RandomService
from test.unit.services.no_annotations.random.truly_random_service import TrulyRandomService
from wireup.ioc.proxy import ContainerProxy


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from test.fixtures import Counter, FooBar, FooBase
from test.services.no_annotations.random.random_service import RandomService
from unittest import TestCase

from test.unit.services.no_annotations.random.random_service import RandomService
from wireup import DependencyContainer, ParameterBag, ServiceLifetime, warmup_container, wire
from wireup.errors import (
DuplicateServiceRegistrationError,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest
from test.services.no_annotations.db_service import DbService

from test.unit.services.no_annotations.db_service import DbService
from wireup.ioc.initialization_context import InitializationContext
from wireup.ioc.types import AnnotatedParameter

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import unittest
from test import services
from test.services import no_annotations, with_annotations
from test.services.with_annotations.env import EnvService

import wireup
from test.unit.services import no_annotations, with_annotations
from test.unit.services.with_annotations.env import EnvService
from wireup import DependencyContainer, ParameterBag, register_all_in_module, warmup_container


Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import re
import unittest

from test import services
from test.unit import services
from wireup import DependencyContainer, ParameterBag, register_all_in_module


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import unittest
from test.services.no_annotations.random.random_service import RandomService

from typing_extensions import Annotated

from test.unit.services.no_annotations.random.random_service import RandomService
from wireup import ServiceLifetime, Wire
from wireup.errors import (
DuplicateServiceRegistrationError,
Expand Down
File renamed without changes.
File renamed without changes.
26 changes: 26 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[tox]
requires =
tox>=4
env_list =
py38-flask3
py38-fastapi

[testenv:py38-flask3]
description = Test flask integration
allowlist_externals = make
deps =
Flask>=3.0.0,<4.0.0
commands =
make install
python -m unittest test/integration/test_flask_integration.py

[testenv:py38-fastapi]
description = Test fastapi integration
allowlist_externals = make
deps =
fastapi
httpx
commands =
make install
python -m unittest test/integration/test_fastapi_integration.py

Loading