Esempio n. 1
0
    def test_cached_object(self):
        expiry = pd.Timestamp("2014")
        before = expiry - pd.Timedelta("1 minute")
        after = expiry + pd.Timedelta("1 minute")

        obj = CachedObject(1, expiry)

        assert obj.unwrap(before) == 1
        assert obj.unwrap(expiry) == 1  # Unwrap on expiry is allowed.
        with pytest.raises(Expired, match=str(expiry)):
            obj.unwrap(after)
Esempio n. 2
0
    def test_cached_object(self):
        expiry = Timestamp('2014')
        before = expiry - Timedelta('1 minute')
        after = expiry + Timedelta('1 minute')

        obj = CachedObject(1, expiry)

        self.assertEqual(obj.unwrap(before), 1)
        self.assertEqual(obj.unwrap(expiry), 1)  # Unwrap on expiry is allowed.
        with self.assertRaises(Expired) as e:
            obj.unwrap(after)
        self.assertEqual(e.exception.args, (expiry,))
Esempio n. 3
0
    def test_cached_object(self):
        expiry = Timestamp("2014")
        before = expiry - Timedelta("1 minute")
        after = expiry + Timedelta("1 minute")

        obj = CachedObject(1, expiry)

        self.assertEqual(obj.unwrap(before), 1)
        self.assertEqual(obj.unwrap(expiry), 1)  # Unwrap on expiry is allowed.
        with self.assertRaises(Expired) as e:
            obj.unwrap(after)
        self.assertEqual(e.exception.args, (expiry, ))