Skip to content

Commit

Permalink
Fix unit test for service_run (#56)
Browse files Browse the repository at this point in the history
* Fix unit test for service_run

* Add conftest.py for unit tests and update test_service.py

---------

Co-authored-by: Michael Woolnough <[email protected]>
  • Loading branch information
donnybeelo and mjkw31 authored Aug 20, 2024
1 parent b677481 commit a93c265
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
11 changes: 0 additions & 11 deletions softpack_core/graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from typing_extensions import Type

from .api import API
from .app import app
from .schemas.base import BaseSchema
from .schemas.environment import EnvironmentSchema
from .schemas.groups import GroupsSchema
Expand All @@ -32,16 +31,6 @@ class GraphQL(API):
]
commands = Typer(help="GraphQL commands.")

@staticmethod
@commands.command("query", help="Execute a GraphQL query.")
def query_command() -> None:
"""Execute a GraphQL query.
Returns:
None.
"""
app.echo("GraphQL Query")

class Schema(strawberry.Schema):
"""GraphQL Schema class."""

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def httpx_post(mocker):


@pytest.fixture
def testable_env_input(mocker) -> EnvironmentInput:
def testable_env_input(mocker) -> EnvironmentInput: # type: ignore
ad = new_test_artifacts()
artifacts: Artifacts = ad["artifacts"]
user = ad["test_user"]
Expand Down
31 changes: 31 additions & 0 deletions tests/unit/test_service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""Copyright (c) 2023 Genome Research Ltd.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""

import multiprocessing
from time import sleep

import httpx
from box import Box

from softpack_core import __version__
from softpack_core.app import app
from softpack_core.service import ServiceAPI


def test_service_run() -> None:
run = multiprocessing.Process(target=ServiceAPI.run)
run.start()
while True:
try:
response = httpx.get(app.url())
break
except httpx.RequestError:
if not run.is_alive():
raise Exception("Service failed to start.")
sleep(5)
run.terminate()
status = Box(response.json())
assert status.softpack.core.version == __version__

0 comments on commit a93c265

Please sign in to comment.