Exemple #1
0
def test_now():
    """verify that the now timestamp generator works as expected"""
    result = now()
    dates = result.split('-')
    assert len(dates) == 3
    assert len(dates[0]) == 4  # year
    assert len(dates[1]) == 2  # month
    assert len(dates[2]) == 2  # day
Exemple #2
0
def test_now():
    """verify that the now timestamp generator works as expected"""
    result = now()
    dates = result.split('-')
    assert len(dates) == 3
    assert len(dates[0]) == 4  # year
    assert len(dates[1]) == 2  # month
    assert len(dates[2]) == 2  # day
Exemple #3
0
    def __init__(self, date=None, days=7):
        """Create a new :class:`Calendar` object

        :param date: Start date of this :class:`Calendar` in the format Ymd
            (i.e. 2011-04-21). Defaults to today
        :param days: Number of days for this :class:`Calendar`. Defaults to 7
            days
        """
        super(Calendar, self).__init__()
        self.date, self.days, self._calendar = date or now(), days, []
        self._get()
Exemple #4
0
    def __init__(self, date=None, days=7):
        """Create a new :class:`Calendar` object

        :param date: Start date of this :class:`Calendar` in the format Ymd
            (i.e. 2011-04-21). Defaults to today
        :param days: Number of days for this :class:`Calendar`. Defaults to 7
            days
        """
        super(Calendar, self).__init__()
        self.date, self.days, self._calendar = date or now(), days, []
        self._get()
Exemple #5
0
def updated_movies(timestamp=None):
    """Returns all movies updated since a timestamp. The server time is in PST.
    To establish a baseline timestamp, you can use the server/time method. It's
    recommended to store the timestamp so you can be efficient in using this
    method.
    """
    ts = timestamp or now()
    data = yield 'movies/updates/{start_date}'.format(start_date=ts)
    to_ret = []
    for movie in data:
        mov = movie.pop('movie')
        extract_ids(mov)
        mov.update({'updated_at': movie.pop('updated_at')})
        to_ret.append(Movie(**mov))
    yield to_ret
Exemple #6
0
def updated_movies(timestamp=None):
    """Returns all movies updated since a timestamp. The server time is in PST.
    To establish a baseline timestamp, you can use the server/time method. It's
    recommended to store the timestamp so you can be efficient in using this
    method.
    """
    ts = timestamp or now()
    data = yield 'movies/updates/{start_date}'.format(start_date=ts)
    to_ret = []
    for movie in data:
        mov = movie.pop('movie')
        extract_ids(mov)
        mov.update({'updated_at': movie.pop('updated_at')})
        to_ret.append(Movie(**mov))
    yield to_ret