File: test_config.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 (44 lines) | stat: -rw-r--r-- 1,395 bytes parent folder | download | duplicates (2)
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
"""Tests for the config module."""

import pytest

from pysmartapp.config import ConfigRequest
from pysmartapp.const import LIFECYCLE_CONFIG, LIFECYCLE_CONFIG_INIT

from .utilities import get_fixture


class TestConfigRequest:
    """Tests for the ConfigRequest class."""

    @staticmethod
    def test_init():
        """Tests the init method."""
        # Arrange
        data = get_fixture('config_init_request')
        # Act
        req = ConfigRequest(data)
        # Assert
        assert req.config_data_raw == data['configurationData']
        assert req.lifecycle == LIFECYCLE_CONFIG
        assert req.execution_id == data['executionId']
        assert req.locale == data['locale']
        assert req.version == data['version']
        assert req.installed_app_id == \
            data['configurationData']['installedAppId']
        assert req.phase == LIFECYCLE_CONFIG_INIT
        assert req.page_id == ''
        assert req.previous_page_id == ''

    @staticmethod
    @pytest.mark.asyncio
    async def test_process_invalid():
        """Tests the process method for an invalid phase."""
        # Arrange
        data = get_fixture('config_init_request')
        data['configurationData']['phase'] = "UNKNOWN"
        # Act
        req = ConfigRequest(data)
        # Assert
        with pytest.raises(ValueError):
            await req.process(None, validate_signature=False)