def test_get_unassigned_barcodes(self):
        with self.assertRaises(ValueError):
            db.get_unassigned_barcodes(999999999)

        obs = db.get_unassigned_barcodes()
        self.assertEqual(obs, [])
        barcodes = db.create_barcodes(3)
        obs = db.get_unassigned_barcodes()
        self.assertEqual(obs, barcodes)
        obs = db.get_unassigned_barcodes(1)
        self.assertEqual(obs, [barcodes[0]])
    def test_get_unassigned_barcodes(self):
        with self.assertRaises(ValueError):
            db.get_unassigned_barcodes(999999999)

        obs = db.get_unassigned_barcodes()
        self.assertEqual(obs, [])
        barcodes = db.create_barcodes(3)
        obs = db.get_unassigned_barcodes()
        self.assertEqual(obs, barcodes)
        obs = db.get_unassigned_barcodes(1)
        self.assertEqual(obs, [barcodes[0]])
Exemple #3
0
    def post(self):
        tag = self.get_argument("tag")
        if not tag:
            tag = None
        projects = self.get_arguments("projects")
        num_swabs = map(int, self.get_arguments("swabs"))
        num_kits = map(int, self.get_arguments("kits"))
        kits = []
        fields = ""
        try:
            kits = db.create_ag_kits(zip(num_swabs, num_kits), tag, projects)
            fields = ','.join(kits[0]._fields)
        except Exception as e:
            msg = "ERROR: %s" % str(e)
        else:
            msg = "Kits created! Please wait for downloads."

        project_names = db.getProjectNames()
        remaining = len(db.get_unassigned_barcodes())
        self.render("ag_new_kit.html",
                    projects=project_names,
                    currentuser=self.current_user,
                    msg=msg,
                    kitinfo=dumps(kits),
                    remaining=remaining,
                    fields=fields)
Exemple #4
0
    def get(self):
        project_names = db.getProjectNames()
        remaining = len(db.get_unassigned_barcodes())

        self.render("ag_new_kit.html", projects=project_names,
                    currentuser=self.current_user, msg="", kitinfo=[],
                    fields="", remaining=remaining)
    def get(self):
        project_names = db.getProjectNames()
        remaining = len(db.get_unassigned_barcodes())

        self.render("ag_new_kit.html", projects=project_names,
                    currentuser=self.current_user, msg="", kitinfo=[],
                    fields="", remaining=remaining)
Exemple #6
0
 def test_get(self):
     self.mock_login_admin()
     response = self.get('/ag_new_kit/')
     self.assertEqual(response.code, 200)
     for project in db.getProjectNames():
         self.assertIn("<option value='%s'>%s</option>" %
                       (project, project), response.body)
     self.assertIn("%i</span> unassigned barcodes" %
                   len(db.get_unassigned_barcodes()), response.body)
 def test_get(self):
     self.mock_login_admin()
     response = self.get('/ag_new_kit/')
     self.assertEqual(response.code, 200)
     obs = response.body.decode('utf-8')
     for project in db.getProjectNames():
         self.assertIn("<option value='%s'>%s</option>" %
                       ((xhtml_escape(project),) * 2), obs)
     self.assertIn("%i</span> unassigned barcodes" %
                   len(db.get_unassigned_barcodes()), obs)
 def test_get(self):
     self.mock_login_admin()
     response = self.get('/ag_new_kit/')
     self.assertEqual(response.code, 200)
     obs = response.body.decode('utf-8')
     for project in db.getProjectNames():
         self.assertIn(
             "<option value='%s'>%s</option>" %
             ((xhtml_escape(project), ) * 2), obs)
     self.assertIn(
         "%i</span> unassigned barcodes" %
         len(db.get_unassigned_barcodes()), obs)
 def get(self):
     project_names = db.getProjectNames()
     remaining = len(db.get_unassigned_barcodes())
     self.render("ag_new_barcode.html",
                 currentuser=self.current_user,
                 projects=project_names,
                 barcodes=[],
                 remaining=remaining,
                 msg="",
                 newbc=[],
                 assignedbc=[],
                 assign_projects="")
    def post(self):
        # create barcodes
        msg = ""
        newbc = []
        assignedbc = []
        projects = []
        action = self.get_argument("action")
        num_barcodes = int(self.get_argument('numbarcodes'))

        if action == "create":
            newbc = db.create_barcodes(num_barcodes)
            msg = ("%d Barcodes created! Please wait for barcode download" %
                   num_barcodes)

        elif action == "assign":
            projects = [
                url_unescape(p).encode('utf-8')
                for p in self.get_arguments('projects')
            ]
            new_project = self.get_argument('newproject').strip()
            try:
                if new_project:
                    db.create_project(new_project)
                    projects.append(new_project)
                assignedbc = db.assign_barcodes(num_barcodes, projects)
            except ValueError as e:
                msg = u"ERROR! %s" % e.message
            else:
                projects = [p.decode('utf-8') for p in projects]
                tmp = u"%d barcodes assigned to %s, please wait for download."
                msg = tmp % (num_barcodes, ", ".join(projects))

        else:
            raise HTTPError(400, 'Unknown action: %s' % action)

        project_names = db.getProjectNames()
        remaining = len(db.get_unassigned_barcodes())
        self.render("ag_new_barcode.html",
                    currentuser=self.current_user,
                    projects=project_names,
                    remaining=remaining,
                    msg=msg,
                    newbc=newbc,
                    assignedbc=assignedbc,
                    assign_projects=", ".join(projects))
Exemple #11
0
    def post(self):
        # create barcodes
        msg = ""
        newbc = []
        assignedbc = []
        projects = []
        action = self.get_argument("action")
        num_barcodes = int(self.get_argument('numbarcodes'))

        if action == "create":
            newbc = db.create_barcodes(num_barcodes)
            msg = ("%d Barcodes created! Please wait for barcode download"
                   % num_barcodes)

        elif action == "assign":
            projects = [url_unescape(p).encode('utf-8')
                        for p in self.get_arguments('projects')]
            new_project = self.get_argument('newproject').strip()
            try:
                if new_project:
                    db.create_project(new_project)
                    projects.append(new_project)
                assignedbc = db.assign_barcodes(num_barcodes, projects)
            except ValueError as e:
                msg = u"ERROR! %s" % e.message
            else:
                projects = [p.decode('utf-8') for p in projects]
                tmp = u"%d barcodes assigned to %s, please wait for download."
                msg = tmp % (num_barcodes, ", ".join(projects))

        else:
            raise HTTPError(400, 'Unknown action: %s' % action)

        project_names = db.getProjectNames()
        remaining = len(db.get_unassigned_barcodes())
        self.render("ag_new_barcode.html", currentuser=self.current_user,
                    projects=project_names, remaining=remaining,
                    msg=msg, newbc=newbc, assignedbc=assignedbc,
                    assign_projects=", ".join(projects))
Exemple #12
0
    def post(self):
        tag = self.get_argument("tag")
        if not tag:
            tag = None
        projects = self.get_arguments("projects")
        num_swabs = map(int, self.get_arguments("swabs"))
        num_kits = map(int, self.get_arguments("kits"))
        kits = []
        fields = ""
        try:
            kits = db.create_ag_kits(zip(num_swabs, num_kits), tag, projects)
            fields = ','.join(kits[0]._fields)
        except Exception as e:
            msg = "ERROR: %s" % str(e)
        else:
            msg = "Kits created! Please wait for downloads."

        project_names = db.getProjectNames()
        remaining = len(db.get_unassigned_barcodes())
        self.render("ag_new_kit.html", projects=project_names,
                    currentuser=self.current_user, msg=msg,
                    kitinfo=dumps(kits), remaining=remaining,
                    fields=fields)
Exemple #13
0
 def get(self):
     project_names = db.getProjectNames()
     remaining = len(db.get_unassigned_barcodes())
     self.render("ag_new_barcode.html", currentuser=self.current_user,
                 projects=project_names, barcodes=[], remaining=remaining,
                 msg="", newbc=[],  assignedbc=[], assign_projects="")