Skip to content

Commit

Permalink
Fix unit test for service_run
Browse files Browse the repository at this point in the history
  • Loading branch information
donnybeelo committed Aug 16, 2024
1 parent b677481 commit be2f687
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 28 deletions.
4 changes: 2 additions & 2 deletions softpack_core/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,15 @@ def clone_repo(self, branch: Optional[str] = None) -> None:
path = self.settings.artifacts.path.expanduser() / ".git"
if path.is_dir():
shutil.rmtree(path)

self.repo = pygit2.clone_repository(
self.settings.artifacts.repo.url,
path=path,
callbacks=self.credentials_callback,
bare=True,
checkout_branch=branch,
)

self.reference = "/".join(
[
"refs/remotes",
Expand Down
10 changes: 0 additions & 10 deletions softpack_core/graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,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
4 changes: 4 additions & 0 deletions softpack_core/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""


import multiprocessing
import urllib.parse
from pathlib import Path

Expand Down Expand Up @@ -51,6 +52,7 @@ def run(
help="Create and use this branch of Artefacts repo.",
),
] = 'main',
serviceReady = None,
) -> None:
"""Start the SoftPack Core REST API service.
Expand All @@ -68,6 +70,8 @@ def run(

artifacts.clone_repo(branch=branch)

if serviceReady is not None:
serviceReady.set()
uvicorn.run(
"softpack_core.app:app.router",
host=app.settings.server.host,
Expand Down
16 changes: 0 additions & 16 deletions tests/unit/conftest.py

This file was deleted.

25 changes: 25 additions & 0 deletions tests/unit/test_service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""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 httpx
from box import Box

from softpack_core import __version__
from softpack_core.app import app
import multiprocessing
from softpack_core.service import ServiceAPI
from time import sleep


def test_service_run() -> None:
ready = multiprocessing.Event()
run = multiprocessing.Process(target=ServiceAPI.run, kwargs={"serviceReady": ready})
run.start()
ready.wait(timeout=120)
response = httpx.get(app.url())
run.terminate()
status = Box(response.json())
assert status.softpack.core.version == __version__

0 comments on commit be2f687

Please sign in to comment.