예제 #1
0
    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)
예제 #2
0
    def post(self):
        barcodes = db.get_barcodes_with_results()
        if len(barcodes) == 0:
            self.write('ERROR: No barcode results available')
            return

        msg = 'Sucessfully updated barcodes to results ready status.'
        try:
            db.mark_results_ready(barcodes)
        except Exception as e:
            msg = 'ERROR: ' + str(e)
        self.write(msg)
예제 #3
0
    def post(self):
        barcodes = db.get_barcodes_with_results()
        if len(barcodes) == 0:
            self.write('ERROR: No barcode results available')
            return

        msg = 'Successfully updated barcodes to results ready status.'
        try:
            db.mark_results_ready(barcodes)
        except Exception as e:
            # TODO: refactor for clear message to the user, see issue: #126
            msg = 'ERROR: ' + str(e)
        self.write(msg)
예제 #4
0
 def test_get_barcodes_with_results(self):
     obs = db.get_barcodes_with_results()
     exp = ['000023299']
     self.assertEqual(obs, exp)
예제 #5
0
 def test_get_barcodes_with_results(self):
     obs = db.get_barcodes_with_results()
     exp = ["000023299"]
     self.assertEqual(obs, exp)