File: __init__.py

package info (click to toggle)
python-aio-georss-client 0.12-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 376 kB
  • sloc: python: 2,656; xml: 513; makefile: 4
file content (71 lines) | stat: -rw-r--r-- 1,886 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""Tests for georss-client library."""
from __future__ import annotations

from typing import Final

from aio_georss_client.feed import GeoRssFeed
from aio_georss_client.feed_entry import DEFAULT_FEATURES, FeedEntry
from aio_georss_client.xml_parser.feed_item import FeedItem
from aio_georss_client.xml_parser.geometry import Geometry

MOCK_HOME_COORDINATES: Final = (0.0, 0.0)


class MockFeedEntry(FeedEntry):
    """Generic feed entry."""

    @property
    def attribution(self) -> str | None:
        """Return attribution."""
        return None


class MockGeoRssFeed(GeoRssFeed[MockFeedEntry]):
    """Mock GeoRSS feed."""

    def _new_entry(
        self,
        home_coordinates: tuple[float, float],
        rss_entry: FeedItem,
        global_data: dict,
    ) -> MockFeedEntry:
        """Generate a new entry."""
        return MockFeedEntry(home_coordinates, rss_entry)


class MockSimpleFeedEntry(FeedEntry):
    """Mock feed entry."""

    def __init__(
        self,
        home_coordinates: tuple[float, float] | None,
        rss_entry: FeedItem,
        features: list[type[Geometry]] = DEFAULT_FEATURES,
    ):
        """Initialise feed entry."""
        super().__init__(home_coordinates, rss_entry)
        self._features = features

    @property
    def features(self) -> list[type[Geometry]]:
        """Return features."""
        return self._features

    @property
    def attribution(self) -> str | None:
        """Return attribution."""
        return "mock attribution"


class MockFeedItem(FeedItem):
    """Mock feed item."""

    def __init__(self, source: dict | None, geometries: list[Geometry] | None):
        """Initialise feed item."""
        super().__init__(source)
        self._geometries = geometries

    @property
    def geometries(self) -> list[Geometry] | None:
        """Return geometries."""
        return self._geometries