File: test_request.py

package info (click to toggle)
pysmartapp 0.3.5-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 340 kB
  • sloc: python: 1,342; makefile: 3
file content (57 lines) | stat: -rw-r--r-- 1,410 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
45
46
47
48
49
50
51
52
53
54
55
56
57
"""Tests for the requests module."""

import pytest

from pysmartapp.request import EmptyDataResponse, Request, Response

from .utilities import get_fixture


class TestResponse:
    """Tests for the Response class."""

    @staticmethod
    def test_to_data():
        """Tests the to_data method."""
        resp = Response()
        with pytest.raises(NotImplementedError):
            resp.to_data()


class TestEmptyDataResponse:
    """Tests for the EmptyDataResponse class."""

    @staticmethod
    def test_init():
        """Tests the init method."""
        resp = EmptyDataResponse('tag')
        assert resp.name == 'tag'

    @staticmethod
    def test_to_data():
        """Tests the to_data method."""
        resp = EmptyDataResponse('tag')
        result = resp.to_data()
        assert result == {'tag': {}}

    @staticmethod
    def test_name():
        """Tests the name setter."""
        resp = EmptyDataResponse('tag')
        resp.name = 'tag2'
        assert resp.name == 'tag2'


class TestRequest:
    """Tests for the Request class."""

    @staticmethod
    @pytest.mark.asyncio
    async def test_process_raises():
        """Tests the to_data method."""
        # Arrange
        data = get_fixture('ping_request')
        resp = Request(data)
        # Act/Assert
        with pytest.raises(NotImplementedError):
            await resp.process(None, validate_signature=False)