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

Fix tests #53

Merged
merged 4 commits into from
Aug 5, 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
3 changes: 2 additions & 1 deletion tests/integration/test_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
"""

import getpass
import os

import ldap

from softpack_core.schemas.groups import Group


def test_groups(mocker) -> None:
username = getpass.getuser()
username = os.environ.get("LDAP_USER", getpass.getuser())
groups = list(Group.from_username(username))
assert len(groups)
assert groups[0].name
Expand Down
53 changes: 0 additions & 53 deletions tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,65 +5,12 @@
"""


import time
from multiprocessing import Process
from threading import Thread

import httpx
import pytest
import requests
from fastapi.testclient import TestClient
from typer.testing import CliRunner

from softpack_core.app import app


@pytest.fixture
def client() -> TestClient:
return TestClient(app.router)


class CLI:
def __init__(self):
self.runner = CliRunner()

def invoke(self, *args, **kwargs):
return self.runner.invoke(app.commands, *args, **kwargs)


@pytest.fixture
def cli() -> CLI:
return CLI()


def service_run():
cli = CLI()
cli.invoke(["service", "run"])


@pytest.fixture
def service_factory():
def create_service(module):
service = module(target=service_run, daemon=True)
service.start()
while True:
try:
response = requests.get(app.url())
if response.status_code == httpx.codes.OK:
break
except requests.ConnectionError:
time.sleep(0.1)
continue
return service

return create_service


@pytest.fixture
def service(service_factory):
return service_factory(Process)


@pytest.fixture
def service_thread(service_factory):
return service_factory(Thread)
13 changes: 0 additions & 13 deletions tests/unit/test_graphql.py

This file was deleted.

17 changes: 0 additions & 17 deletions tests/unit/test_service.py

This file was deleted.

Loading