Esempio n. 1
0
 def test_old_path_setter(self):
     """Set self._old_path to data if it's valid, else raise ValueError."""
     rd = Redirect('/old/path', '/new/path', 302)
     rd.old_path = '/older/path'
     assert rd._old_path == '/older/path'
     with pytest.raises(ValueError):
         rd.old_path = 'not/root/relative/path'
Esempio n. 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