Ejemplo n.º 1
0
    def test_active_during_recent(self):
        # User has no bookmarks, so he/she was not active recently
        assert not self.user.active_during_recent()

        random_bookmark = BookmarkRule(self.user).bookmark
        random_bookmark.time = datetime.now()
        assert self.user.active_during_recent()
Ejemplo n.º 2
0
    def test_bookmark_counts_by_date(self):
        date_bookmark_pair = []
        for i in range(random.randint(5, 10)):
            today_without_time = self.__truncate_time_from_date(datetime.today())
            random_date = today_without_time - timedelta(random.randint(1, 364))

            random_bookmark = BookmarkRule(self.user).bookmark
            random_bookmark.time = random_date

            date_bookmark_pair.append(random_date)

        date_bookmark_count_pair = dict(Counter(date_bookmark_pair))

        counts_by_date = json.loads(self.user.bookmark_counts_by_date())

        for pair in counts_by_date:
            result_date = datetime.strptime(pair['date'], "%Y-%m-%d")
            result_count = pair['count']

            assert result_date in date_bookmark_count_pair
            assert result_count == date_bookmark_count_pair[result_date]