예제 #1
0
 def testUserMissing2CertsFrom2Labs(self):
     user = api.get_user_by_username('bobjones2019')
     cert1 = api.get_certs()[0]
     cert2 = api.get_certs()[1]
     lab1 = api.get_labs()[0]
     lab2 = api.get_labs()[1]
     data = urlencode({'cert': cert1['id'], 'redirect_url': '/labs/'})
     self.client.post('/api/labs/' + str(lab1['id']) + '/certificates/',
                      data=data,
                      content_type="application/x-www-form-urlencoded")
     data = urlencode({'cert': cert2['id'], 'redirect_url': '/labs/'})
     self.client.post('/api/labs/' + str(lab2['id']) + '/certificates/',
                      data=data,
                      content_type="application/x-www-form-urlencoded")
     data = urlencode({
         'redirect_url': '/users',
         'user': user.username,
         'role': 0
     })
     self.client.post('/api/labs/' + str(lab1['id']) + '/users/',
                      data=data,
                      content_type="application/x-www-form-urlencoded")
     data = urlencode({
         'redirect_url': '/users',
         'user': user.username,
         'role': 0
     })
     self.client.post('/api/labs/' + str(lab2['id']) + '/users/',
                      data=data,
                      content_type="application/x-www-form-urlencoded")
     missingCerts = api.get_missing_certs(user.id)
     self.assertEqual(len(missingCerts), 2)
예제 #2
0
 def testAddPIandUserToLab(self):
     userPI = setUpUser(self)
     lab = api.get_labs()[0]
     data = urlencode({
         'user': userPI.username,
         'role': 1,
         'redirect_url': ['/labs/5', '/labs/5']
     })
     self.client.post('/api/labs/' + str(lab['id']) + '/users/',
                      data=data,
                      content_type="application/x-www-form-urlencoded")
     user = setUpUser(self)
     lab = api.get_labs()[0]
     data = urlencode({
         'user': user.username,
         'role': 0,
         'redirect_url': ['/labs/5', '/labs/5']
     })
     self.client.post('/api/labs/' + str(lab['id']) + '/users/',
                      data=data,
                      content_type="application/x-www-form-urlencoded")
     userLabsPI = api.get_user_labs(userPI.id,
                                    is_principal_investigator=True)
     self.assertEqual(userLabsPI[0]['name'], 'test')
     userLabs = api.get_user_labs(user.id)
     self.assertEqual(userLabs[0]['name'], 'test')
예제 #3
0
 def testDeleteLabs(self):
     ogLabNum = len(api.get_labs())
     lab = api.get_labs()[0]
     deleteForm = urlencode({'redirect_url': '/labs/'})
     self.client.post('/api/labs/' + str(lab['id']) + '/delete/',
                      data=deleteForm,
                      content_type="application/x-www-form-urlencoded")
     labs = api.get_labs()
     self.assertEqual(len(labs), ogLabNum - 1)
예제 #4
0
 def testEditLabs(self):
     lab = api.get_labs()[0]
     newName = urlencode({
         'name': 'new test name',
         'redirect_url': '/labs/'
     })
     self.client.post('/api/labs/' + str(lab['id']) + '/update/',
                      data=newName,
                      content_type="application/x-www-form-urlencoded")
     lab = api.get_labs()[0]
     self.assertEqual(lab['name'], 'new test name')
예제 #5
0
 def testUserMissingOneCert(self):
     user = api.get_user_by_username('bobjones2019')
     cert1 = api.get_certs()[0]
     cert2 = api.get_certs()[1]
     lab = api.get_labs()[0]
     data = urlencode({'cert': cert1['id'], 'redirect_url': '/labs/'})
     self.client.post('/api/labs/' + str(lab['id']) + '/certificates/',
                      data=data,
                      content_type="application/x-www-form-urlencoded")
     data = urlencode({'cert': cert2['id'], 'redirect_url': '/labs/'})
     self.client.post('/api/labs/' + str(lab['id']) + '/certificates/',
                      data=data,
                      content_type="application/x-www-form-urlencoded")
     data = urlencode({
         'redirect_url': '/users',
         'user': user.username,
         'role': 0
     })
     self.client.post('/api/labs/' + str(lab['id']) + '/users/',
                      data=data,
                      content_type="application/x-www-form-urlencoded")
     api.update_or_create_user_cert(user_id=user.id,
                                    cert_id=cert1['id'],
                                    cert_file='testCert.pdf',
                                    completion_date="2019-07-03",
                                    expiry_date="2019-07-03")
     missingCerts = api.get_missing_lab_certs(user.id, lab['id'])
     self.assertEqual(missingCerts[0]['name'], cert2['name'])
예제 #6
0
 def testAddUserTo2Labs(self):
     user = setUpUser(self)
     lab1 = api.get_labs()[0]
     lab2 = api.get_labs()[1]
     data = urlencode({
         'user': user.username,
         'role': 0,
         'redirect_url': ['/labs/5', '/labs/5']
     })
     self.client.post('/api/labs/' + str(lab1['id']) + '/users/',
                      data=data,
                      content_type="application/x-www-form-urlencoded")
     self.client.post('/api/labs/' + str(lab2['id']) + '/users/',
                      data=data,
                      content_type="application/x-www-form-urlencoded")
     userLabs = api.get_user_labs(user.id)
     self.assertEqual(len(userLabs), 2)
예제 #7
0
 def testEmailFromLab(self):
     user = api.get_user_by_username('admin')
     lab = api.get_labs()[0]
     data = urlencode({
         'user': user.username,
         'role': 0,
         'redirect_url': ['/labs/5', '/labs/5']
     })
     self.client.post('/api/labs/' + str(lab['id']) + '/users/',
                      data=data,
                      content_type="application/x-www-form-urlencoded")
     self.assertEqual(len(mail.outbox), 1)
예제 #8
0
 def testAddUserToLab(self):
     user = setUpUser(self)
     lab = api.get_labs()[0]
     data = urlencode({
         'user': user.username,
         'role': 0,
         'redirect_url': ['/labs/5', '/labs/5']
     })
     response = self.client.post(
         '/api/labs/' + str(lab['id']) + '/users/',
         data=data,
         content_type="application/x-www-form-urlencoded")
     self.assertEqual(response.status_code, 302)
     userLabs = api.get_user_labs(user.id)
     self.assertEqual(userLabs[0]['name'], 'test')
예제 #9
0
 def testAddCertToLab(self):
     setUpLab(self)
     cert = api.get_certs()[0]
     lab = api.get_labs()[0]
     data = urlencode({
         'cert': cert['id'],
         'redirect_url': ['/area/' + str(lab['id'])]
     })
     response = self.client.post(
         '/api/labs/' + str(lab['id']) + '/certificates/',
         data=data,
         content_type="application/x-www-form-urlencoded")
     self.assertEqual(response.status_code, 302)
     labCerts = api.get_lab_certs(lab['id'])
     self.assertEqual(labCerts[0]['name'], 'testing')
예제 #10
0
 def testSwitchToLabUser(self):
     user = api.get_user_by_username('admin')
     lab = api.get_labs()[0]
     data = urlencode({
         'user': user.username,
         'role': 1,
         'redirect_url': ['/labs/5', '/labs/5']
     })
     self.client.post('/api/labs/' + str(lab['id']) + '/users/',
                      data=data,
                      content_type="application/x-www-form-urlencoded")
     data = urlencode({'redirect_url': '/labs/3/'})
     self.client.post('/api/users/' + str(user.id) + '/labs/' +
                      str(lab['id']) + '/switch_lab_role/',
                      data=data,
                      content_type="application/x-www-form-urlencoded")
     self.assertEqual(
         len(api.get_user_labs(user.id, is_principal_investigator=True)), 0)
예제 #11
0
 def testRemovePIFromLab(self):
     user = setUpUser(self)
     lab = api.get_labs()[0]
     data = urlencode({
         'user': user.username,
         'role': 1,
         'redirect_url': ['/labs/5', '/labs/5']
     })
     self.client.post('/api/labs/' + str(lab['id']) + '/users/',
                      data=data,
                      content_type="application/x-www-form-urlencoded")
     data = urlencode({'redirect_url': '/area/' + str(lab['id'])})
     self.client.post('/api/users/' + str(user.id) + '/labs/' +
                      str(lab['id']) + '/delete/',
                      data=data,
                      content_type="application/x-www-form-urlencoded")
     userLabs = api.get_user_labs(user.id)
     self.assertEqual(len(userLabs), 0)
예제 #12
0
 def testUserMissingCerts(self):
     user = api.get_user_by_username('bobjones2019')
     cert = api.get_certs()[0]
     lab = api.get_labs()[0]
     data = urlencode({'cert': cert['id'], 'redirect_url': '/labs/'})
     self.client.post('/api/labs/' + str(lab['id']) + '/certificates/',
                      data=data,
                      content_type="application/x-www-form-urlencoded")
     data = urlencode({
         'redirect_url': '/area/' + str(lab['id']),
         'user': user.username,
         'role': 0
     })
     response = self.client.post(
         '/api/labs/' + str(lab['id']) + '/users/',
         data=data,
         content_type="application/x-www-form-urlencoded")
     self.assertEqual(response.status_code, 302)
     missingCerts = api.get_missing_lab_certs(user.id, lab['id'])
     self.assertEqual(missingCerts[0]['name'], 'testing')
예제 #13
0
 def testAdd2PIToLab(self):
     user1 = setUpUser(self)
     user2 = api.get_user_by_username('admin')
     lab = api.get_labs()[0]
     data = urlencode({
         'user': user1.username,
         'role': 1,
         'redirect_url': ['/labs/5', '/labs/5']
     })
     self.client.post('/api/labs/' + str(lab['id']) + '/users/',
                      data=data,
                      content_type="application/x-www-form-urlencoded")
     data = urlencode({
         'user': user2.username,
         'role': 1,
         'redirect_url': ['/labs/5', '/labs/5']
     })
     self.client.post('/api/labs/' + str(lab['id']) + '/users/',
                      data=data,
                      content_type="application/x-www-form-urlencoded")
     usersLab = api.get_users_in_lab(lab['id'])
예제 #14
0
 def testAddLabs(self):
     lab = api.get_labs()[0]
     self.assertEqual(lab['name'], 'test')