'Regression for #3031: Archives around Feburary include only one month'

def test_archive_month_includes_only_month(self):

    author = Author(name='John    Smith')
    author.save()
    first_second_of_feb = datetime(2004, 2, 1, 0, 0, 1)
    first_second_of_mar = datetime(2004, 3, 1, 0, 0, 1)
    two_seconds = timedelta(0, 2, 0)
    article = Article(title='example', author=author)
    article.date_created = first_second_of_feb
    article.save()
    response = self.client.get('/views/date_based/archive_month/2004/02/')
    self.assertEqual(response.status_code, 200)
    self.assertEqual(response.context['next_month'], date(2004, 3, 1))
    self.assertEqual(response.context['previous_month'], date(2004, 1, 1))
    article.date_created = (first_second_of_feb - two_seconds)
    article.save()
    response = self.client.get('/views/date_based/archive_month/2004/02/')
    self.assertEqual(response.status_code, 404)
    article.date_created = (first_second_of_mar - two_seconds)
    article.save()
    response = self.client.get('/views/date_based/archive_month/2004/02/')
    self.assertEqual(response.status_code, 200)
    self.assertEqual(response.context['next_month'], date(2004, 3, 1))
    self.assertEqual(response.context['previous_month'], date(2004, 1, 1))
    article.date_created = first_second_of_mar
    article.save()
    response = self.client.get('/views/date_based/archive_month/2004/02/')
    self.assertEqual(response.status_code, 404)
    article2 = DateArticle(title='example', author=author)
    article2.date_created = first_second_of_feb.date()
    article2.save()
    response = self.client.get('/views/date_based/datefield/archive_month/2004/02/')
    self.assertEqual(response.status_code, 200)
    self.assertEqual(response.context['next_month'], date(2004, 3, 1))
    self.assertEqual(response.context['previous_month'], date(2004, 1, 1))
    article2.date_created = (first_second_of_feb - two_seconds).date()
    article2.save()
    response = self.client.get('/views/date_based/datefield/archive_month/2004/02/')
    self.assertEqual(response.status_code, 404)
    article2.date_created = (first_second_of_mar - two_seconds).date()
    article2.save()
    response = self.client.get('/views/date_based/datefield/archive_month/2004/02/')
    self.assertEqual(response.status_code, 200)
    self.assertEqual(response.context['next_month'], date(2004, 3, 1))
    self.assertEqual(response.context['previous_month'], date(2004, 1, 1))
    article2.date_created = first_second_of_mar.date()
    article2.save()
    response = self.client.get('/views/date_based/datefield/archive_month/2004/02/')
    self.assertEqual(response.status_code, 404)
    now = datetime.now()
    prev_month = now.date().replace(day=1)
    if (prev_month.month == 1):
        prev_month = prev_month.replace(year=(prev_month.year - 1), month=12)
    else:
        prev_month = prev_month.replace(month=(prev_month.month - 1))
    article2.date_created = now
    article2.save()
    response = self.client.get(('/views/date_based/datefield/archive_month/%s/' % now.strftime('%Y/%m')))
    self.assertEqual(response.status_code, 200)
    self.assertEqual(response.context['next_month'], None)
    self.assertEqual(response.context['previous_month'], prev_month)
