Beispiel #1
0
    def test_date_created_setter(self, mock_dt):
        """Set with given datetime, or with current utc datetime if none given.

        Raise a TypeError if given non-datetime data.
        """
        rd = Redirect('/old/path', '/new/path', 302)
        dt = datetime(2012, 12, 21)
        assert rd._date_created == datetime(2000, 1, 1)
        rd.date_created = dt
        assert rd._date_created == dt
        with pytest.raises(TypeError):
            rd.date_created = '12/12/12'
Beispiel #2
0
 def test_eq(self):
     """Return true if all data in two Redirects is the same."""
     dt = datetime.utcnow()
     rd1 = Redirect('/old/path', '/new/path', 302, dt)
     rd2 = Redirect('/old/path', '/new/path', 302, dt)
     assert rd1 is not rd2
     assert rd1 == rd2
     rd2.new_path = '/newer/path'
     assert rd1 != rd2
     rd2.new_path = '/new/path'
     assert rd1 == rd2
     rd2.old_path = '/oldest/path'
     assert rd1 != rd2
     rd2.old_path = '/old/path'
     assert rd1 == rd2
     rd2.status_code = 301
     assert rd1 != rd2
     rd2.status_code = 302
     assert rd1 == rd2
     rd2.date_created = datetime.utcnow()
     assert rd1 != rd2
     rd2.date_created = dt
     assert rd1 == rd2