Tested Model.get_next/prev_by_FIELD() on unsaved models.

This commit is contained in:
Tim Graham 2016-10-11 12:09:37 -04:00 committed by GitHub
parent f1664a2734
commit d4cfeca006
1 changed files with 7 additions and 0 deletions

View File

@ -178,6 +178,13 @@ class ModelTests(TestCase):
e.get_previous_by_when().when, datetime.datetime(2000, 1, 1, 6, 1, 1)
)
def test_get_next_prev_by_field_unsaved(self):
msg = 'get_next/get_previous cannot be used on unsaved objects.'
with self.assertRaisesMessage(ValueError, msg):
Event().get_next_by_when()
with self.assertRaisesMessage(ValueError, msg):
Event().get_previous_by_when()
def test_primary_key_foreign_key_types(self):
# Check Department and Worker (non-default PK type)
d = Department.objects.create(id=10, name="IT")