Esempio n. 1
0
    def post(self):
        """process a post request  do a verification or return validation errors"""

        verify_request = self.get_request()
        message = ""
        if self.result.data == 'accept':

            if self.validate():
                if (self.id_back_photo_invalid.data
                        or self.id_front_photo_invalid.data
                        or self.owner_photo_invalid.data
                        or self.voter_reg_photo_invalid.data):
                    message = alert(
                        "One or more of the photos have been "
                        "marked invalid. Invalid photos are not "
                        "allowed when accepting an id.", "danger")
                elif not self.state.data:
                    message = alert("State selection is invalid", "danger")
                elif not self.ballot_id.data:
                    message = alert("Ballot ID is invalid", "danger")
                else:
                    response = VerificationResponse(
                        True, None, verify_request,
                        date_str_to_iso(self.id_expiration_date.data), True,
                        True, True, True)

                    db.resolve_request(verify_request.id, response)

        else:
            # we are rejecting the data make sure we have a reason or an invalid
            # photo
            if (self.rejection_reason.data or self.id_back_photo_invalid.data
                    or self.id_front_photo_invalid.data
                    or self.owner_photo_invalid.data
                    or self.voter_reg_photo_invalid.data):

                response = VerificationResponse(
                    False, self.rejection_reason.data, verify_request, None,
                    not self.owner_photo_invalid.data,
                    not self.voter_reg_photo_invalid.data,
                    not self.id_front_photo_invalid.data,
                    not self.id_back_photo_invalid.data)

                db.resolve_request(verify_request.id, response)

            else:
                message = alert(
                    "Please enter a rejection reason or select "
                    "an invalid photo", "danger")

        return verify_request, message
Esempio n. 2
0
class TestVerificationResponse(unittest.TestCase):
    def setUp(self):
        """Call before every test case."""

        self.response = VerificationResponse(
            True, 'rejection reason', Identity(), '2014-1-1', True, True,
            True, False)

    def test_verification_response_property_accepted(self):
        self.assertTrue(self.response.accepted)

    def test_verification_response_to_json(self):
        self.response.to_json()

    def test_verification_response_to_dict(self):
        self.assertEquals(self.response.to_dict()['expiration_date'],
                          '2014-1-1')
Esempio n. 3
0
class TestVerificationResponse(unittest.TestCase):
    def setUp(self):
        """Call before every test case."""

        self.response = VerificationResponse(True, 'rejection reason',
                                             Identity(), '2014-1-1', True,
                                             True, True, False)

    def test_verification_response_property_accepted(self):
        self.assertTrue(self.response.accepted)

    def test_verification_response_to_json(self):
        self.response.to_json()

    def test_verification_response_to_dict(self):
        self.assertEquals(self.response.to_dict()['expiration_date'],
                          '2014-1-1')
Esempio n. 4
0
    def test_api_verifier_resolve_request(self):
        create_request()
        verify_request = Identity(api.take_next_request()['result'])

        today = datetime.combine(date.today(), datetime.min.time())
        x = VerificationResponse(True, None, verify_request, today.isoformat(),
                                 True, True, True, True)

        response = api.verifier_resolve_request(verify_request.id, x.to_dict())
        self.assertFalse("error" in response)

        create_request()
        verify_request = Identity(api.take_next_request()['result'])
        x = VerificationResponse(False, "this is the rejection reason",
                                 verify_request, None, True, True, False, True)

        response = api.verifier_resolve_request(verify_request.id, x.to_dict())
        self.assertFalse("error" in response)
Esempio n. 5
0
    def test_api_verifier_resolve_request(self):
        create_request()
        verify_request = Identity(api.take_next_request()['result'])

        today = datetime.combine(date.today(), datetime.min.time())
        x = VerificationResponse(True, None, verify_request, today.isoformat(),
                                 True, True, True, True)

        response = api.verifier_resolve_request(verify_request.id, x.to_dict())
        self.assertFalse("error" in response)

        create_request()
        verify_request = Identity(api.take_next_request()['result'])
        x = VerificationResponse(False, "this is the rejection reason",
                                 verify_request, None, True, True, False, True)

        response = api.verifier_resolve_request(verify_request.id, x.to_dict())
        self.assertFalse("error" in response)
Esempio n. 6
0
    def setUp(self):
        """Call before every test case."""

        self.response = VerificationResponse(
            True, 'rejection reason', Identity(), '2014-1-1', True, True,
            True, False)
Esempio n. 7
0
    def setUp(self):
        """Call before every test case."""

        self.response = VerificationResponse(True, 'rejection reason',
                                             Identity(), '2014-1-1', True,
                                             True, True, False)