How to use the apiron.DiscoverableService function in apiron

To help you get started, we’ve selected a few apiron examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ithaka / apiron / tests / service / test_discoverable.py View on Github external
import pytest

from apiron import DiscoverableService


class FakeResolver:
    @staticmethod
    def resolve(service_name):
        return ["fake"]


class FakeService(DiscoverableService):
    service_name = "fake-service"
    host_resolver_class = FakeResolver


@pytest.fixture(scope="class")
def service():
    return FakeService


class TestDiscoverableService:
    def test_get_hosts_returns_hosts_from_resolver(self, service):
        assert ["fake"] == service.get_hosts()

    def test_str_method_on_class(self, service):
        assert "fake-service" == str(service)