def test_utc_now(self, mock_datetime): mock_datetime.datetime.utcnow.return_value = datetime.datetime( 2002, 10, 27, 1, 30) in_utc = DateUtils.utc_now() self.assertEqual(in_utc.strftime(self.fmt), '2002-10-27 01:30:00 UTC+0000')
def test_created_modified(self): utc_now = DateUtils.utc_now() res = mommy.make(Resident) self.assertLess((res.created_at - utc_now).total_seconds(), 10) original_created_at = res.created_at original_modified_at = res.modified_at res.first_name = 'John' res.save() res.refresh_from_db() self.assertEqual(res.created_at, original_created_at) self.assertGreater(res.modified_at, original_modified_at) self.assertLess( (res.modified_at - original_created_at).total_seconds(), 10)