File: conftest.py

package info (click to toggle)
pysmartapp 0.3.5-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 360 kB
  • sloc: python: 1,358; makefile: 3
file content (46 lines) | stat: -rw-r--r-- 1,189 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""Define common test configuraiton."""

import pytest

from pysmartapp.dispatch import Dispatcher
from pysmartapp.smartapp import SmartApp, SmartAppManager


@pytest.fixture
def smartapp() -> SmartApp:
    """Fixture for testing against the SmartApp class."""
    app = SmartApp(dispatcher=Dispatcher())
    app.name = 'SmartApp'
    app.description = 'SmartApp Description'
    app.permissions.append('l:devices')
    app.config_app_id = 'myapp'
    return app


@pytest.fixture
def manager() -> SmartAppManager:
    """Fixture for testing against the SmartAppManager class."""
    return SmartAppManager('/path/to/app',
                           dispatcher=Dispatcher())


@pytest.fixture
def handler():
    """Fixture handler to mock in the dispatcher."""
    def target(*args, **kwargs):
        target.fired = True
        target.args = args
        target.kwargs = kwargs
    target.fired = False
    return target


@pytest.fixture
def async_handler():
    """Fixture async handler to mock in the dispatcher."""
    async def target(*args, **kwargs):
        target.fired = True
        target.args = args
        target.kwargs = kwargs
    target.fired = False
    return target