Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gromdimon committed Mar 11, 2024
1 parent 52eb861 commit 52c014e
Show file tree
Hide file tree
Showing 11 changed files with 539 additions and 58 deletions.
66 changes: 33 additions & 33 deletions .github/workflows/main-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,43 +27,43 @@ jobs:
- name: Lint source code
run: make lint

# Test:
# runs-on: ubuntu-latest
# needs:
# - Lint
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# with:
# lfs: 'true'
Test:
runs-on: ubuntu-latest
needs:
- Lint
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
lfs: 'true'

# - name: Set up Python 3.12
# uses: actions/setup-python@v5
# with:
# python-version: "3.12"
# cache: "pipenv"
# cache-dependency-path: |
# Pipfile.lock
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pipenv"
cache-dependency-path: |
Pipfile.lock
# - name: Install pipenv and deps
# run: |
# python -m pip install --upgrade pipenv wheel
# make deps
- name: Install pipenv and deps
run: |
python -m pip install --upgrade pipenv wheel
make deps
# - name: Install dependencies
# run: make deps
- name: Install dependencies
run: make deps

# - name: Run tests
# run: make test
- name: Run tests
run: make test

# - name: Build docs
# run: make docs
# - name: Build docs
# run: make docs

# - name: Upload backend coverage reports to Codecov
# uses: codecov/codecov-action@v4
# with:
# flags: backend
# directory: backend
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# - name: Upload backend coverage reports to Codecov
# uses: codecov/codecov-action@v4
# with:
# flags: main
# directory: .
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

41 changes: 18 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DIRS_PYTHON := src
DIRS_PYTHON := src tests

.PHONY: help
help:
Expand Down Expand Up @@ -63,28 +63,23 @@ lint-mypy:
example_run:
pipenv run python -m src.main 13-113803407-G-A --genome_release hg19

# .PHONY: test
# test:
# pipenv run pytest \
# -n auto \
# --cov-report term-missing \
# --cov-report lcov \
# --cov=app \
# tests/

# .PHONY: test-ci
# test-ci:
# pipenv run pytest \
# --cov-report term-missing \
# --cov-report lcov \
# --cov=app \
# tests/

# .PHONY: ci
# ci: \
# deps \
# lint \
# test-ci
.PHONY: test
test:
pipenv run pytest tests/

.PHONY: test-ci
test-ci:
pipenv run pytest \
--cov-report term-missing \
--cov-report lcov \
--cov=src \
tests/

.PHONY: ci
ci: \
deps \
lint \
test-ci

# .PHONY: docs
# docs:
Expand Down
3 changes: 3 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ pydantic = "*"
pydantic-settings = "*"

[dev-packages]
pytest = "*"
aioresponses = "*"
pytest-asyncio = "*"

[requires]
python_version = "3.12"
437 changes: 435 additions & 2 deletions Pipfile.lock

Large diffs are not rendered by default.

Empty file added src/core/__init__.py
Empty file.
Empty file added tests/__init__.py
Empty file.
Empty file added tests/api/__init__.py
Empty file.
50 changes: 50 additions & 0 deletions tests/api/test_dotty.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import pytest
from aioresponses import aioresponses

from src.api.dotty import DottyClient


@pytest.mark.asyncio
async def test_to_spdi_success():
"""Test to_spdi method with a successful response."""
with aioresponses() as m:
mock_response = {"success": True, "value": "mocked response data"}
m.get(
"https://example.com/dotty/api/v1/to-spdi?q=test_query&assembly=GRCh38",
payload=mock_response,
status=200,
)

client = DottyClient(api_base_url="https://example.com/dotty")
response = await client.to_spdi("test_query", "GRCh38")

assert response == mock_response


@pytest.mark.asyncio
async def test_to_spdi_failure():
"""Test to_spdi method with a failed response."""
with aioresponses() as m:
m.get("https://example.com/dotty/api/v1/to-spdi?q=test_query&assembly=GRCh38", status=404)

client = DottyClient(api_base_url="https://example.com/dotty")
response = await client.to_spdi("test_query", "GRCh38")

assert response is None


@pytest.mark.asyncio
async def test_to_spdi_grch37_assembly():
"""Test to_spdi method with default assembly."""
with aioresponses() as m:
mock_response = {"success": True, "value": "mocked response data"}
m.get(
"https://example.com/dotty/api/v1/to-spdi?q=test_query&assembly=GRCh37",
payload=mock_response,
status=200,
)

client = DottyClient(api_base_url="https://example.com/dotty")
response = await client.to_spdi("test_query", "GRCh37")

assert response == mock_response
Empty file added tests/test_genome_builds.py
Empty file.
Empty file added tests/test_pvs1.py
Empty file.
Empty file added tests/test_seqvar.py
Empty file.

0 comments on commit 52c014e

Please sign in to comment.