def test_display_date(self): """ If a date is passed to get_slides, it should return slides for that date instead of the current date. """ eq_(list(get_slides(date(2013, 5, 1))), ['carousel/test5.html', 'carousel/test6.html'])
def test_now(self, mock_date): """ If a date isn't passed to get_slides, it should return slides for the current date. """ mock_date.today.return_value = date(2013, 4, 8) eq_(list(get_slides()), ['carousel/test1.html', 'carousel/test2.html'])
def test_default(self): """ If the date given to get_slides doesn't match any of the configured dates, it should return the default slides. """ eq_(list(get_slides(date(2012, 2, 2))), ['carousel/slide-two.html', 'carousel/slide-three.html'])
def test_default(self): """ If the date given to get_slides doesn't match any of the configured dates, it should return the default slides. """ defaults = [ 'carousel/blogpost_winbig.html', 'carousel/blogpost_getmobilized.html', 'carousel/blogpost_makeyourflickawinner.html' ] eq_(list(get_slides(date(2012, 2, 2))), defaults)
def home(request): """Home page.""" # Check to see if the user wants to view promos for a specific date. promo_date = request.GET.get('date', None) if promo_date: try: promo_date = datetime.strptime(promo_date, ISO_DATE_FMT).date() except ValueError: promo_date = None # Failure defaults to today's date. return render(request, 'home.html', { 'slides': carousel.get_slides(promo_date) })