Exemplo n.º 1
0
    def test_ar_states_without_batch(self):
        wf = getToolByName(self.portal, 'portal_workflow')
        self.portal.REQUEST['entry'] = self.ar1.id
        self.portal.REQUEST['_authenticator'] = self.getAuthenticator()

        value = json.loads(barcode_entry(self.portal, self.portal.REQUEST)())
        if value.get('failure', False):
            self.fail('failure code in json return: ' + value['error'])
        state = wf.getInfoFor(self.ar1, 'review_state')
        self.assertTrue(state == 'sample_received',
                        'AR is in %s state; should be sample_received' % state)

        value = json.loads(barcode_entry(self.portal, self.portal.REQUEST)())
        if value.get('failure', False):
            self.fail('failure code in json return: ' + value['error'])
        expected = self.ar1.absolute_url() + "/manage_results"
        self.assertEqual(value['url'], expected,
                         "AR redirect should be  %s but it's %s" % (
                             expected, value['url']))

        changeWorkflowState(self.ar1, 'bika_ar_workflow', 'verified')
        wf.getWorkflowById('bika_ar_workflow').updateRoleMappingsFor(self.ar1)
        self.ar1.reindexObject(idxs=['allowedRolesAndUsers'])

        value = json.loads(barcode_entry(self.portal, self.portal.REQUEST)())
        if value.get('failure', False):
            self.fail('failure code in json return: ' + value['error'])
        expected = self.ar1.absolute_url()
        self.assertEqual(value['url'], expected,
                         "AR redirect should be  %s but it's %s" % (
                             expected, value['url']))
Exemplo n.º 2
0
    def test_ar_states_without_batch(self):
        wf = getToolByName(self.portal, 'portal_workflow')
        self.portal.REQUEST['entry'] = self.ar1.id
        self.portal.REQUEST['_authenticator'] = self.getAuthenticator()

        value = json.loads(barcode_entry(self.portal, self.portal.REQUEST)())
        if value.get('failure', False):
            self.fail('failure code in json return: ' + value['error'])
        state = wf.getInfoFor(self.ar1, 'review_state')
        self.assertTrue(state == 'sample_received',
                        'AR is in %s state; should be sample_received' % state)

        value = json.loads(barcode_entry(self.portal, self.portal.REQUEST)())
        if value.get('failure', False):
            self.fail('failure code in json return: ' + value['error'])
        expected = self.ar1.absolute_url() + "/manage_results"
        self.assertEqual(
            value['url'], expected,
            "AR redirect should be  %s but it's %s" % (expected, value['url']))

        changeWorkflowState(self.ar1, 'bika_ar_workflow', 'verified')
        wf.getWorkflowById('bika_ar_workflow').updateRoleMappingsFor(self.ar1)
        self.ar1.reindexObject(idxs=['allowedRolesAndUsers'])

        value = json.loads(barcode_entry(self.portal, self.portal.REQUEST)())
        if value.get('failure', False):
            self.fail('failure code in json return: ' + value['error'])
        expected = self.ar1.absolute_url()
        self.assertEqual(
            value['url'], expected,
            "AR redirect should be  %s but it's %s" % (expected, value['url']))
Exemplo n.º 3
0
def test_sample_with_single_ar_redirects_to_AR(self):
    self.portal.REQUEST['entry'] = self.sample2.id
    self.portal.REQUEST['_authenticator'] = self.getAuthenticator()
    value = json.loads(barcode_entry(self.portal, self.portal.REQUEST)())
    expected = self.ar3.absolute_url()
    self.assertEqual(value['url'], expected,
                     "sample2 redirect should be ar3:%s but it's %s" % (
                         expected, value['url']))
Exemplo n.º 4
0
def test_sample_with_single_ar_redirects_to_AR(self):
    self.portal.REQUEST['entry'] = self.sample2.id
    self.portal.REQUEST['_authenticator'] = self.getAuthenticator()
    value = json.loads(barcode_entry(self.portal, self.portal.REQUEST)())
    expected = self.ar3.absolute_url()
    self.assertEqual(value['url'], expected,
                     "sample2 redirect should be ar3:%s but it's %s" % (
                         expected, value['url']))
Exemplo n.º 5
0
 def test_batchbook_view(self):
     self.portal.REQUEST['entry'] = self.ar2.id
     self.portal.REQUEST['_authenticator'] = self.getAuthenticator()
     value = json.loads(barcode_entry(self.portal, self.portal.REQUEST)())
     expected = self.ar2.getBatch().absolute_url() + "/batchbook"
     self.assertEqual(value['url'], expected,
                      "AR redirect should be batchbook %s but it's %s" % (
                          expected, value['url']))
Exemplo n.º 6
0
 def test_sample_with_multiple_ars_redirects_to_self(self):
     self.portal.REQUEST['entry'] = self.ar1.id
     self.portal.REQUEST['_authenticator'] = self.getAuthenticator()
     value = json.loads(barcode_entry(self.portal, self.portal.REQUEST)())
     expected = self.ar1.absolute_url() + "/manage_results"
     self.assertEqual(value['url'], expected,
                      "ar1 redirect should be self:%s but it's %s" % (
                          expected, value['url']))
Exemplo n.º 7
0
 def test_batchbook_view(self):
     self.portal.REQUEST['entry'] = self.ar2.id
     self.portal.REQUEST['_authenticator'] = self.getAuthenticator()
     value = json.loads(barcode_entry(self.portal, self.portal.REQUEST)())
     expected = self.ar2.getBatch().absolute_url() + "/batchbook"
     self.assertEqual(value['url'], expected,
                      "AR redirect should be batchbook %s but it's %s" % (
                          expected, value['url']))
Exemplo n.º 8
0
 def test_batchbook_view(self):
     self.portal.REQUEST['entry'] = self.ar2.id
     self.portal.REQUEST['_authenticator'] = self.getAuthenticator()
     value = json.loads(barcode_entry(self.portal, self.portal.REQUEST)())
     expected = self.ar2.getBatch().absolute_url() + "/batchbook"
     err_msg = value['error'] if hasattr(value, 'error') else 'No error'
     self.assertEqual(value['failure'], False, err_msg)
     self.assertEqual(value['url'], expected,
                      "AR redirect should be batchbook %s but it's %s" % (
                          expected, value['url']))
Exemplo n.º 9
0
 def test_batchbook_view(self):
     self.portal.REQUEST['entry'] = self.ar2.id
     self.portal.REQUEST['_authenticator'] = self.getAuthenticator()
     value = json.loads(barcode_entry(self.portal, self.portal.REQUEST)())
     expected = self.ar2.getBatch().absolute_url() + "/batchbook"
     err_msg = value['error'] if hasattr(value, 'error') else 'No error'
     self.assertEqual(value['failure'], False, err_msg)
     self.assertEqual(value['url'], expected,
                      "AR redirect should be batchbook %s but it's %s" % (
                          expected, value['url']))