Exemplo n.º 1
0
 def test_from_response_body(self):
     frame = Frame.from_response_body(_FRAME_DATA,
                                      0,
                                      URL_PAGE,
                                      cache_path="cache_path")
     assert frame.frame_id == _FRAME_ID
     assert frame["sensor1"].path == "test1.png"
     assert frame["sensor1"].timestamp == 1614945883
     assert frame["sensor1"].url.get() == "url1"
     assert frame["sensor1"].cache_path == os.path.join(
         "cache_path", "test1.png")
     assert frame["sensor2"].path == "test2.png"
     assert frame["sensor2"].timestamp == 1614945884
     assert frame["sensor2"].url.get() == "url2"
     assert frame["sensor2"].cache_path == os.path.join(
         "cache_path", "test2.png")
Exemplo n.º 2
0
    def _generate_frames(self,
                         segment_name: str,
                         offset: int = 0,
                         limit: int = 128) -> Generator[Frame, None, int]:
        response = self._list_data_details(segment_name, offset, limit)

        url_page = LazyPage.from_items(
            offset,
            limit,
            lambda offset, limit: self._generate_urls(segment_name, offset,
                                                      limit),
            ({frame["sensorName"]: frame["url"]
              for frame in item["frame"]} for item in response["dataDetails"]),
        )

        for index, item in enumerate(response["dataDetails"]):
            yield Frame.from_response_body(item, index, url_page)

        return response["totalCount"]  # type: ignore[no-any-return]