def testGetLastCommitOfDate_failed(self, find_commit): commit_before = ('2a66bac4', '2019-03-17T23:50:16-07:00') find_commit.side_effect = [None, commit_before] date = pd.Timestamp('2019-03-17 04:01:01', tz=pinboard.TZ) with self.assertRaises(ValueError): pinboard.GetLastCommitOfDate(date) cutoff_date = pd.Timestamp('2019-03-18 00:00:00', tz=pinboard.TZ) find_commit.assert_has_calls([mock.call(after_date=cutoff_date)])
def testGetLastCommitOfDate_simple(self, find_commit): commit_before = ('2a66bac4', '2019-03-17T23:50:16-07:00') commit_after = ('5aefdb31', '2019-03-18T02:41:58-07:00') find_commit.side_effect = [commit_after, commit_before] date = pd.Timestamp('2019-03-17 04:01:01', tz=pinboard.TZ) return_value = pinboard.GetLastCommitOfDate(date) cutoff_date = pd.Timestamp('2019-03-18 00:00:00', tz=pinboard.TZ) find_commit.assert_has_calls([ mock.call(after_date=cutoff_date), mock.call(before_date=cutoff_date)]) self.assertEqual(return_value, commit_before)