Esempio n. 1
0
    def test_iter_ends_after_end_returns_nothing(self):
        now = datetime.now()
        before_time = now - timedelta(hours=1)
        after_time = before_time - timedelta(hours=1)
        iterator = mock_by_seconds(after_time - timedelta(minutes=5), 5)

        items = list(
            under_test.iterate_by_time_window(iterator, before_time,
                                              after_time, "the_time"))
        assert not items
Esempio n. 2
0
    def test_items_in_window_are_returned(self):
        now = datetime.now()
        before_time = now - timedelta(hours=1)
        after_time = before_time - timedelta(hours=1)
        iterator = mock_by_seconds(now, 100)

        items = list(
            under_test.iterate_by_time_window(iterator, before_time,
                                              after_time, "the_time"))
        assert (60 // 7) + 1 == len(items)
Esempio n. 3
0
    def patches_by_project_time_window(
        self,
        project_id: str,
        before: datetime,
        after: datetime,
        params: Dict = None,
        time_attr: str = "create_time",
    ) -> Iterable[Patch]:
        """
        Get an iterator over the patches for the given time window.

        :param project_id: Id of project to query.
        :param params: Parameters to pass to endpoint.
        :param before: Return patches earlier than this timestamp
        :param after: Return patches later than this timestamp.
        :param time_attr: Attributes to use to window timestamps.
        :return: Iterator for the given time window.
        """
        return iterate_by_time_window(
            self.patches_by_project(project_id, params), before, after,
            time_attr)
Esempio n. 4
0
    def versions_by_project_time_window(
        self,
        project_id: str,
        before: datetime,
        after: datetime,
        requester: Requester = Requester.GITTER_REQUEST,
        time_attr: str = "create_time",
    ) -> Iterable[Version]:
        """
        Get an iterator over the patches for the given time window.

        :param project_id: Id of project to query.
        :param requester: Type of version to query
        :param before: Return versions earlier than this timestamp.
        :param after: Return versions later than this timestamp.
        :param time_attr: Attributes to use to window timestamps.
        :return: Iterator for the given time window.
        """
        return iterate_by_time_window(
            self.versions_by_project(project_id, requester), before, after,
            time_attr)