def test_get(self): self.mock_login_admin() # check that error is raised for unknown barcode response = self.get("/ag_edit_barcode/", {"barcode": "unknown"}) self.assertEqual(response.code, 500) # make sure return code 400 is returned, if barcode is not given response = self.get("/ag_edit_barcode/", {}) self.assertEqual(response.code, 400) # check if page is rendered properly barcode = db.get_barcodes_with_results()[0] response = self.get("/ag_edit_barcode/", {"barcode": barcode}) self.assertEqual(response.code, 200) details = db.getAGBarcodeDetails(barcode) l = db.search_kits(details["ag_kit_id"])[0] self.assertIn('name="barcode" id="barcode" value="%s"' % barcode, response.body) for s in db.human_sites: if details["site_sampled"] == str(s): self.assertIn('<option value="%s" selected>%s</option>' % (str(s), str(s)), response.body) else: self.assertIn('<option value="%s">%s</option>' % (str(s), str(s)), response.body) for e in db.general_sites: if details["environment_sampled"] == str(e): self.assertIn('<option value="%s" selected>%s</option>' % (str(e), str(e)), response.body) else: self.assertIn('<option value="%s">%s</option>' % (str(e), str(e)), response.body) for p in db.getHumanParticipants(l) + db.getAnimalParticipants(l): if details["participant_name"] == str(p): self.assertIn('<option value="%s" selected>%s</option>' % (str(p), str(p)), response.body) else: self.assertIn('<option value="%s" >%s</option>' % (str(p), str(p)), response.body)
def get(self): barcode = self.get_argument('barcode', None) if barcode is not None: details = db.getAGBarcodeDetails(barcode) ag_login_id = db.search_kits(details['ag_kit_id'])[0] site_sampled = db.human_sites environment_sampled = db.general_sites participants = db.getHumanParticipants(ag_login_id) + \ db.getAnimalParticipants(ag_login_id) self.render("ag_edit_barcode.html", response=None, barcode=barcode, sites_sampled=site_sampled, details=details, environments_sampled=environment_sampled, participants=participants, currentuser=self.current_user)
def post(self): term = self.get_argument('search_term') results = {} # search participant info logins = db.search_participant_info(term) results = set(logins) # search kit info and add to resluts logins = db.search_kits(term) results = results | set(logins) # search barcode and add to results logins = db.search_barcodes(term) results = results | set(logins) # search handout kits handouts = db.search_handout_kits(term) # now take the ag_login_ids and collect the information to display display_results = [] # list of dictionatries for login in results: login_display = {} login_display['login_info'] = db.get_login_info(login) login_display['humans'] = db.getHumanParticipants( login) login_display['animals'] = db.getAnimalParticipants( login) login_display['kit'] = db.get_kit_info_by_login(login) for kit in login_display['kit']: barcode_info = {} ag_barcodes = db.get_barcode_info_by_kit_id( kit['ag_kit_id']) barcode_info = {} for ag_barcode in ag_barcodes: barcode_info[ag_barcode['barcode']] = {} barcode_info[ag_barcode['barcode']]['ag_info'] = ag_barcode lab_barcode_info = db.get_barcode_details( ag_barcode['barcode']) plate = db.get_plate_for_barcode( ag_barcode['barcode']) barcode_info[ag_barcode['barcode']]['barcode_info'] = \ lab_barcode_info barcode_info[ag_barcode['barcode']]['plate'] = plate kit['barcode_info'] = barcode_info display_results.append(login_display) # now render the page self.render("ag_search.html", results=display_results, handouts=handouts, currentuser=self.current_user)
def get(self): barcode = self.get_argument('barcode', None) if barcode is not None: details = db.getAGBarcodeDetails(barcode) ag_login_id = db.search_kits(details['ag_kit_id'])[0] site_sampled = db.human_sites environment_sampled = db.general_sites participants = db.getHumanParticipants(ag_login_id) + \ db.getAnimalParticipants(ag_login_id) self.render("ag_edit_barcode.html", response=None, barcode=barcode, sites_sampled=site_sampled, details=details, environments_sampled=environment_sampled, participants=participants, currentuser=self.current_user) else: self.set_status(400)
def test_getAnimalParticipantsNotPresent(self): i = "00711b0a-67d6-0fed-e050-8a800c5d7570" res = db.getAnimalParticipants(i) self.assertEqual(res, [])
def test_getAnimalParticipants(self): i = "ed5ab96f-fe3b-ead5-e040-8a80115d1c4b" res = db.getAnimalParticipants(i) # we can't compare to scrubbed participant names, thus we only check # number of names. self.assertTrue(len(res) == 1)
def test_getAnimalParticipants(self): i = "ed5ab96f-fe3b-ead5-e040-8a80115d1c4b" res = db.getAnimalParticipants(i) exp = ["REMOVED-0"] self.assertItemsEqual(res, exp)
def test_getAnimalParticipants(self): i = "ed5ab96f-fe3b-ead5-e040-8a80115d1c4b" res = db.getAnimalParticipants(i) exp = ['REMOVED-0'] self.assertItemsEqual(res, exp)