def test_update_event(self): event = EventSession() event.testing_center = "new center" event.course_id = "new/course/id" event.course_event_id = "new event" event.proctor = self.user event.save() self.assertEqual(event.end_date, None) factory = APIRequestFactory() event_data = { 'status': EventSession.ARCHIVED, 'notify': 'new notify', 'comment': 'new comment' } request = factory.patch( '/api/event_session/%s' % event.pk, data=event_data) force_authenticate(request, user=self.user) view = views_ui.EventSessionViewSet.as_view( {'patch': 'partial_update'}) response = view(request, pk=event.pk) response.render() self.assertEqual(response.status_code, status.HTTP_200_OK) data = json.loads(response.content) self.assertEqual(type(data), dict) event = ArchivedEventSession.objects.get(pk=data['id']) self.assertDictContainsSubset({ "status": event.status, "notify": event.notify, }, event_data ) self.assertNotEqual(event.end_date, None)
def setUp(self): self.user = User.objects.create_user( 'test', '*****@*****.**', 'testpassword' ) Permission.objects.create( user=self.user, object_id='*', object_type='*' ) event = EventSession() event.testing_center = "new center" event.course_id = "new course" event.course_event_id = "new event" event.proctor = self.user event.save() exam = Exam() exam.exam_code = 'examCode' exam.organization = 'organization' exam.duration = 1 exam.reviewed_exam = 'reviewedExam' exam.reviewer_notes = 'reviewerNotes' exam.exam_password = '******' exam.exam_sponsor = 'examSponsor' exam.exam_name = 'examName' exam.ssi_product = 'ssiProduct' exam.first_name = 'firstName' exam.last_name = 'lastName' exam.username = '******' exam.user_id = 1 exam.email = '*****@*****.**' exam.exam_id = event.course_event_id exam.course_id = event.course_id exam.event = event exam.save() self.exam = exam