• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

box / box-python-sdk / 7583613459

19 Jan 2024 12:14PM UTC coverage: 93.536% (+0.005%) from 93.531%
7583613459

push

github

web-flow
fix: Update exception file get download URL (#866)

* fix: Update exception file get download URL

* fix: Update exception file get download URL

3 of 3 new or added lines in 1 file covered. (100.0%)

3473 of 3713 relevant lines covered (93.54%)

1.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/boxsdk/pagination/page.py
1
import copy
2✔
2

3
from collections.abc import Sequence
2✔
4
from typing import TYPE_CHECKING
2✔
5

6
if TYPE_CHECKING:
2✔
7
    from boxsdk.session.session import Session
×
8
    from boxsdk.util.translator import Translator
×
9
    from boxsdk.object.base_object import BaseObject
×
10

11

12
class Page(Sequence):
2✔
13
    """
14
    A sequence of BaseObjects that belong to a page returned from a paging api call.
15

16
    The Page makes available detailed response data for page requests.
17
    """
18
    _item_entries_key_name = "entries"
2✔
19

20
    def __init__(self, session: 'Session', response_object: dict):
2✔
21
        """
22
        :param session:
23
            The Box session used to make the request that generated the response.
24
        :param response_object:
25
            The parsed HTTP response from Box after requesting more pages.
26
        """
27
        super().__init__()
2✔
28
        self._session = session
2✔
29
        self._response_object = response_object
2✔
30

31
    @property
2✔
32
    def _translator(self) -> 'Translator':
2✔
33
        """
34
        The translator used for translating Box API JSON responses into `BaseAPIJSONObject` smart objects.
35
        """
36
        return self._session.translator
2✔
37

38
    @property
2✔
39
    def response_object(self) -> dict:
2✔
40
        """
41
        Return a copy of the response object for this Page.
42
        """
43
        return copy.deepcopy(self._response_object)
2✔
44

45
    def __getitem__(self, key: str) -> 'BaseObject':
2✔
46
        """
47
        Try to get the attribute from the API response object.
48

49
        :param key:
50
            The attribute to retrieve from the API response object.
51
        """
52
        item_json = self._response_object[self._item_entries_key_name][key]
2✔
53
        return self._translator.translate(self._session, item_json)
2✔
54

55
    def __len__(self) -> int:
2✔
56
        """
57
        Get the number of items in the page.
58
        """
59
        return len(self._response_object[self._item_entries_key_name])
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc