def test_can_save_released_exhibition(self): exhibition = Exhibition(title='New Exhibition', description='description goes here', released_at=timezone.now()) self.assertTrue(exhibition.released_yet) student_artwork = Artwork(title='New Artwork', code='// code goes here', author=self.user) staff_artwork = Artwork(title='New Artwork', code='// code goes here', author=self.staff_user) # only authors can submit artwork submission = Submission(exhibition=exhibition, artwork=student_artwork) self.assertTrue(submission.can_save(self.user)) self.assertFalse(submission.can_save(self.staff_user)) self.assertFalse(submission.can_save(self.super_user)) submission = Submission(exhibition=exhibition, artwork=staff_artwork) self.assertFalse(submission.can_save(self.user)) self.assertTrue(submission.can_save(self.staff_user)) self.assertFalse(submission.can_save(self.super_user))
def test_can_save_unreleased_exhibition(self): exhibition = Exhibition( title='New Exhibition', description='description goes here', released_at=timezone.now() + timedelta(hours=24)) self.assertFalse(exhibition.released_yet) student_artwork = Artwork(title='New Artwork', code='// code goes here', author=self.user) staff_artwork = Artwork(title='New Artwork', code='// code goes here', author=self.staff_user) # students cannot submit to unreleased exhibitions submission = Submission(exhibition=exhibition, artwork=student_artwork) self.assertFalse(submission.can_save(self.user)) self.assertFalse(submission.can_save(self.staff_user)) self.assertFalse(submission.can_save(self.super_user)) # but staff can submission = Submission(exhibition=exhibition, artwork=staff_artwork) self.assertFalse(submission.can_save(self.user)) self.assertTrue(submission.can_save(self.staff_user)) self.assertFalse(submission.can_save(self.super_user))