Skip to content
Snippets Groups Projects
conftest.py 1.17 KiB
Newer Older
from hgitaly.service.commit import CommitServicer
from hgitaly.service.ref import RefServicer
from hgitaly.service.repository_service import RepositoryServiceServicer
from hgitaly.stub.commit_pb2_grpc import add_CommitServiceServicer_to_server
from hgitaly.stub.ref_pb2_grpc import add_RefServiceServicer_to_server
from hgitaly.stub.repository_service_pb2_grpc import (
    add_RepositoryServiceServicer_to_server
)

@pytest.fixture(scope='module')
def grpc_server(_grpc_server, grpc_addr, server_repos_root):
    storages = dict(default=str(server_repos_root / 'default').encode())
    add_CommitServiceServicer_to_server(CommitServicer(storages),
    add_RefServiceServicer_to_server(RefServicer(storages),
    add_RepositoryServiceServicer_to_server(
        RepositoryServiceServicer(storages),
    _grpc_server.add_insecure_port(grpc_addr)
    _grpc_server.start()
    yield _grpc_server
    _grpc_server.stop(grace=None)


@pytest.fixture(scope='module')
def server_repos_root(tmp_path_factory):
    return tmp_path_factory.mktemp("server-repos")