# -*- coding: utf-8 -*-
from unittest import mock

from homehub_backend.lib import services


class FakeService(services.BaseService):
    KIND = 'testing.FakeService'

    @classmethod
    def make_data(cls):
        return services.ServiceData(data='spam')

    async def current_data(self):
        return self.make_data()

    start = mock.AsyncMock()

    stop = mock.AsyncMock()

    async def capability(self, param):
        return param


class FakeGlobalService(services.BaseService):
    IS_GLOBAL = True
    KIND = 'testing.FakeGlobalService'

    @classmethod
    def reset(cls):
        if cls.INSTANCE:
            cls.INSTANCE.start.reset_mock()
            cls.INSTANCE.stop.reset_mock()
            cls.INSTANCE = None

    def __init__(self, *args, **kwargs):
        super(FakeGlobalService, self).__init__(*args, **kwargs)
        self.data = services.ServiceData(data='spam')

    async def current_data(self):
        return self.data

    start = mock.AsyncMock()

    stop = mock.AsyncMock()
