(self, mocked_datetime)
| 353 | @unittest.skipIf(platform.architecture()[0] == "32bit", "The Year 2038 problem.") |
| 354 | @mock.patch("django.utils.http.datetime") |
| 355 | def test_parsing_rfc850(self, mocked_datetime): |
| 356 | mocked_datetime.side_effect = datetime |
| 357 | now_1 = datetime(2019, 11, 6, 8, 49, 37, tzinfo=UTC) |
| 358 | now_2 = datetime(2020, 11, 6, 8, 49, 37, tzinfo=UTC) |
| 359 | now_3 = datetime(2048, 11, 6, 8, 49, 37, tzinfo=UTC) |
| 360 | tests = ( |
| 361 | ( |
| 362 | now_1, |
| 363 | "Tuesday, 31-Dec-69 08:49:37 GMT", |
| 364 | datetime(2069, 12, 31, 8, 49, 37, tzinfo=UTC), |
| 365 | ), |
| 366 | ( |
| 367 | now_1, |
| 368 | "Tuesday, 10-Nov-70 08:49:37 GMT", |
| 369 | datetime(1970, 11, 10, 8, 49, 37, tzinfo=UTC), |
| 370 | ), |
| 371 | ( |
| 372 | now_1, |
| 373 | "Sunday, 06-Nov-94 08:49:37 GMT", |
| 374 | datetime(1994, 11, 6, 8, 49, 37, tzinfo=UTC), |
| 375 | ), |
| 376 | ( |
| 377 | now_2, |
| 378 | "Wednesday, 31-Dec-70 08:49:37 GMT", |
| 379 | datetime(2070, 12, 31, 8, 49, 37, tzinfo=UTC), |
| 380 | ), |
| 381 | ( |
| 382 | now_2, |
| 383 | "Friday, 31-Dec-71 08:49:37 GMT", |
| 384 | datetime(1971, 12, 31, 8, 49, 37, tzinfo=UTC), |
| 385 | ), |
| 386 | ( |
| 387 | now_3, |
| 388 | "Sunday, 31-Dec-00 08:49:37 GMT", |
| 389 | datetime(2000, 12, 31, 8, 49, 37, tzinfo=UTC), |
| 390 | ), |
| 391 | ( |
| 392 | now_3, |
| 393 | "Friday, 31-Dec-99 08:49:37 GMT", |
| 394 | datetime(1999, 12, 31, 8, 49, 37, tzinfo=UTC), |
| 395 | ), |
| 396 | ) |
| 397 | for now, rfc850str, expected_date in tests: |
| 398 | with self.subTest(rfc850str=rfc850str): |
| 399 | mocked_datetime.now.return_value = now |
| 400 | parsed = parse_http_date(rfc850str) |
| 401 | mocked_datetime.now.assert_called_once_with(tz=UTC) |
| 402 | self.assertEqual( |
| 403 | datetime.fromtimestamp(parsed, UTC), |
| 404 | expected_date, |
| 405 | ) |
| 406 | mocked_datetime.reset_mock() |
| 407 | |
| 408 | def test_parsing_asctime(self): |
| 409 | parsed = parse_http_date("Sun Nov 6 08:49:37 1994") |
nothing calls this directly
no test coverage detected