def test_list_stats(self): student = Student.new_student( 'bob', 'bob smith', email='*****@*****.**', year=2015 ).key.get(use_cache=False) roshreview.RoshReviewUserStats.new_stats( student, { "email": "*****@*****.**", "training_level": "Resident", "pgy": -5, "percentage_complete": 0, "cumulative_performance": 0, "category_performances": {} } ).key.get(use_cache=False) alice = self.new_user(is_staff=True) headers = self.login(user=alice) resp = self.app.get( '%s/dashboard/roshreview/stats' % api.path, headers=headers ).json api.validate('RoshReviewUserStatsList', resp) self.assertEqual(1, len(resp['stats'])) self.assertEqual(0, resp['stats'][0]['performance'])
def test_staff_list(self): """Should list staff""" bob = self.new_user(name="Bob Smith", is_admin=True) headers = self.login(user=bob) response = self.app.get('%s/dashboard/staff' % api.path, headers=headers).json api.validate('UserList', response) self.assertEqual(1, len(response['users']))
def test_empty_list(self): headers = self.logoff() resp = self.app.get( '%s/dashboard/pgy' % api.path, headers=headers, ).json api.validate('PGYList', resp) self.assertEqual(0, len(resp['pgy']))
def test_post(self): bob = self.new_user(name="Bob Smith", is_admin=True) headers = self.login(user=bob) resp = self.app.post( '%s/dashboard/uploadurl/students' % api.path, headers=headers ).json api.validate('BlobStoreUploadInfo', resp)
def test_get_stats(self): alice = self.new_user(is_staff=True) headers = self.login(user=alice) resp = self.app.get( '%s/dashboard/roshreview/stats/A0001' % api.path, headers=headers ).json api.validate('RoshReviewUserStats', resp)
def test_get_empty_stats_list(self): alice = self.new_user(is_staff=True) headers = self.login(user=alice) resp = self.app.get( '%s/dashboard/firstaid/stats' % api.path, headers=headers ).json api.validate('FirstAidUserStatsList', resp)
def test_logged_as_admin(self): alice = self.new_user(is_admin=True) headers = self.login(user=alice) response = self.app.get('%s/dashboard/user' % api.path, headers=headers).json api.validate('User', response) self.assertTrue(response['isLoggedIn']) self.assertFalse(response['isStaff']) self.assertTrue(response['isAdmin'])
def test_staff_list(self): """Should list staff""" bob = self.new_user(name="Bob Smith", is_admin=True) headers = self.login(user=bob) response = self.app.get( '%s/dashboard/staff' % api.path, headers=headers ).json api.validate('UserList', response) self.assertEqual(1, len(response['users']))
def test_get_exams_logged_as_staff(self): self.add_exam() bob = self.new_user(name="Bob Smith", is_staff=True) headers = self.login(user=bob) resp = self.app.get( '%s/dashboard/assessments/exams' % api.path, headers=headers ).json api.validate('AssessmentExamList', resp) self.assertEqual(1, len(resp['exams']))
def test_logged_as_admin(self): alice = self.new_user(is_admin=True) headers = self.login(user=alice) response = self.app.get( '%s/dashboard/user' % api.path, headers=headers ).json api.validate('User', response) self.assertTrue(response['isLoggedIn']) self.assertFalse(response['isStaff']) self.assertTrue(response['isAdmin'])
def test_get_user_exams_logged_as_owner(self): self.add_exam() headers = self.login(user=self.alice) resp = self.app.get( '%s/dashboard/assessments/exams?studentId=%s' % ( api.path, self.alice.student_id, ), headers=headers ).json api.validate('AssessmentExamList', resp) self.assertEqual(1, len(resp['exams']))
def test_get_exam(self): exam = self.add_exam() bob = self.new_user(name="Bob Smith", is_staff=True) headers = self.login(user=bob) resp = self.app.get( '%s/dashboard/assessments/exams/%s' % ( api.path, exam.key.id(), ), headers=headers ).json api.validate('AssessmentExam', resp) self.assertIn('studentResults', resp) self.assertEqual(1, len(resp['studentResults']))
def test_get_list(self): Student.new_student( 'bob', 'bob smith', email='*****@*****.**', year=2016 ).key.get(use_cache=False) Student.new_student( 'alice', 'alice smith', email='*****@*****.**', year=2015 ).key.get(use_cache=False) headers = self.logoff() resp = self.app.get( '%s/dashboard/pgy' % api.path, headers=headers, ) api.validate('PGYList', resp.json) self.assertEqual(2, len(resp.json['pgy'])) self.assertEqual('max-age=300, public', resp.headers['Cache-Control'])
def test_student_list_with_cursor(self): """Should list students using the cursor for a previous request """ bob = self.new_user("Bob Smith", is_admin=True) headers = self.login(user=bob) response = self.app.get('%s/dashboard/students' % api.path, headers=headers).json # might be empty in production response = self.app.get('%s/dashboard/students' % api.path, { 'cursor': response.get('cursor') }, headers=headers).json api.validate('StudentList', response) self.assertEqual(response.get('students'), [])
def test_get_list(self): firstaid.FirstAidActivityTopic.new_topic({ "code": "OBG", "id": 28, "name": "OB/GYN", "order": 28, "step": 2, "synonyms": [""], "type": "Disciplines" }).key.get(use_cache=False) resp = self.app.get( '%s/dashboard/firstaid/topics' % api.path, status=200 ).json api.validate('TopicList', resp) self.assertEqual(1, len(resp['topics']))
def test_get_list(self): Student.new_student('bob', 'bob smith', email='*****@*****.**', year=2016).key.get(use_cache=False) Student.new_student('alice', 'alice smith', email='*****@*****.**', year=2015).key.get(use_cache=False) headers = self.logoff() resp = self.app.get( '%s/dashboard/pgy' % api.path, headers=headers, ) api.validate('PGYList', resp.json) self.assertEqual(2, len(resp.json['pgy'])) self.assertEqual('max-age=300, public', resp.headers['Cache-Control'])
def test_staff_list_with_cursor(self): """Should list staff using the cursor for a previous request """ bob = self.new_user(name="Bob Smith", is_admin=True) headers = self.login(user=bob) response = self.app.get('%s/dashboard/staff' % api.path, headers=headers).json # might be empty in production self.assertTrue(response.get('cursor')) response = self.app.get('%s/dashboard/staff' % api.path, { 'cursor': response.get('cursor') }, headers=headers).json api.validate('UserList', response) self.assertEqual(0, len(response['users']))
def test_student_list_with_cursor(self): """Should list students using the cursor for a previous request """ bob = self.new_user("Bob Smith", is_admin=True) headers = self.login(user=bob) response = self.app.get( '%s/dashboard/students' % api.path, headers=headers ).json # might be empty in production response = self.app.get( '%s/dashboard/students' % api.path, {'cursor': response.get('cursor')}, headers=headers ).json api.validate('StudentList', response) self.assertEqual(response.get('students'), [])
def test_staff_list_with_cursor(self): """Should list staff using the cursor for a previous request """ bob = self.new_user(name="Bob Smith", is_admin=True) headers = self.login(user=bob) response = self.app.get( '%s/dashboard/staff' % api.path, headers=headers ).json # might be empty in production self.assertTrue(response.get('cursor')) response = self.app.get( '%s/dashboard/staff' % api.path, {'cursor': response.get('cursor')}, headers=headers ).json api.validate('UserList', response) self.assertEqual(0, len(response['users']))
def test_get_empty_list(self): resp = self.app.get( '%s/dashboard/firstaid/topics' % api.path, status=200 ).json api.validate('TopicList', resp)
def validate(data): api.validate('AssessmentExamData', data)
def validate(data): api.validate('DocumentData', data)
def validate(data): api.validate("StudentData", data)
def validate(data): """Validate student data schema. """ api.validate("UserData", data)
def validate(data): api.validate('StudentData', data)
def test_post(self): bob = self.new_user(name="Bob Smith", is_admin=True) headers = self.login(user=bob) resp = self.app.post('%s/dashboard/uploadurl/students' % api.path, headers=headers).json api.validate('BlobStoreUploadInfo', resp)
def validate(data): api.validate("AssessmentExamData", data)
def validate(data): api.validate("DocumentData", data)