def test_get(self):
        ag_login_id = '0077c686-b0ad-11f8-e050-8a800c5d1877'
        self.mock_login_admin()
        email = db.get_login_info(ag_login_id)[0]['email']
        response = self.get('/ag_edit_participant/', {'email': email})
        self.assertEqual(response.code, 200)

        # check that all relevant user information is rendered on HTML side
        login = db.get_login_by_email(email)
        for key, value in login.items():
            if not isinstance(key, unicode):
                key = key.decode('utf-8')
            if key == 'zip':
                key = u'zipcode'
            elif key == 'ag_login_id':
                continue
            if not isinstance(value, unicode):
                value = value.decode('utf-8')
            key = xhtml_escape(key.encode('utf-8'))
            value = xhtml_escape(value.encode('utf-8'))
            self.assertIn(('</td><td><input type="text" name="%s" id="%s" '
                           'value="%s"></td></tr>') % (key, key, value),
                          response.body)

        # check what happens if user with email does not exist.
        # TODO: we should create a better error message in the handler to be
        # displayed, see issue: #115
        response = self.get('/ag_edit_participant/?email=notInDB')
        self.assertIn('AN ERROR HAS OCCURED!', response.body)
        self.assertEqual(response.code, 500)

        # TODO: similarly if no email, i.e. user, is given. Issue: #115
        response = self.get('/ag_edit_participant/?email=')
        self.assertIn('AN ERROR HAS OCCURED!', response.body)
        self.assertEqual(response.code, 500)
Exemplo n.º 2
0
 def get(self):
     email = self.get_argument('email', None)
     if email is not None:
         email = unquote(email)
         login = db.get_login_by_email(email)
         self.render("ag_edit_participant.html", response=None,
                     login=login, currentuser=self.current_user)
Exemplo n.º 3
0
    def test_get(self):
        self.mock_login_admin()
        email = "*****@*****.**"
        response = self.get("/ag_edit_participant/?email=%s" % email)
        self.assertEqual(response.code, 200)

        # check that all relevant user information is rendered on HTML side
        login = db.get_login_by_email(email)
        for key, value in login.items():
            if key == "zip":
                key = "zipcode"
            elif key == "ag_login_id":
                continue
            value = value.decode("utf-8")
            self.assertIn(
                ('</td><td><input type="text" name="%s" id="%s" ' 'value="%s"></td></tr>') % (key, key, value),
                response.body.decode("utf-8"),
            )

        # check what happens if user with email does not exist.
        # TODO: we should create a better error message in the handler to be
        # displayed, see issue: #115
        response = self.get("/ag_edit_participant/?email=notInDB")
        self.assertIn("AN ERROR HAS OCCURED!", response.body)
        self.assertEqual(response.code, 500)

        # TODO: similarly if no email, i.e. user, is given. Issue: #115
        response = self.get("/ag_edit_participant/?email=")
        self.assertIn("AN ERROR HAS OCCURED!", response.body)
        self.assertEqual(response.code, 500)
Exemplo n.º 4
0
 def get(self):
     email = self.get_argument('email', None)
     if email is not None:
         email = unquote(email)
         login = db.get_login_by_email(email)
         self.render("ag_edit_participant.html",
                     response=None,
                     login=login,
                     currentuser=self.current_user)
 def get(self):
     email = self.get_argument('email', None)
     if email is not None:
         login = db.get_login_by_email(email)
         if not login:
             raise ValueError("Couldn't retrieve the login information for "
                              "the given email: %s" % email)
         self.render("ag_edit_participant.html",
                     response=None,
                     login=login,
                     currentuser=self.current_user)
    def test_post(self):
        self.mock_login_admin()

        name = u'TESTDUDE'
        address = u'123 fake test street'
        city = u'testcity'
        state = u'\xc3\x8ele-de-France'
        zipcode = u'1L2 2G3'
        country = 'United Kingdom'
        ag_login_id = '0023cc03-3332-eec6-e050-8a800c5d3c04'
        email = db.get_login_info(ag_login_id)[0]['email']

        # check a regular update
        response = self.post('/ag_edit_participant/',
                             {'email': email,
                              'name': name,
                              'address': address,
                              'city': city,
                              'state': state,
                              'zipcode': zipcode,
                              'country': country,
                              'ag_login_id': ag_login_id})
        self.assertEqual(response.code, 200)
        self.assertIn('Participant was updated successfully', response.body)

        # pull it back out and verify
        response = self.get('/ag_edit_participant/', {'email': email})
        self.assertEqual(response.code, 200)
        # check that all relevant user information is rendered on HTML side
        login = db.get_login_by_email(email)
        for key, value in login.items():
            if key == 'zip':
                key = 'zipcode'
            elif key == 'ag_login_id':
                continue
            value = value.decode('utf-8')
            self.assertIn('</td><td><input type="text" name="%s" id="%s" '
                          'value="%s"></td></tr>'
                          % (key, key, xhtml_escape(value)),
                          response.body.decode('utf-8'))

        # wrong ag_login_id
        response = self.post('/ag_edit_participant/',
                             {'email': email,
                              'name': name,
                              'address': address,
                              'city': city,
                              'state': state,
                              'zipcode': zipcode,
                              'country': country,
                              'ag_login_id': 'wrongID'})
        self.assertEqual(response.code, 200)
        self.assertIn('Error Updating Particpant Info', response.body)

        # check missing arguments
        response = self.post('/ag_edit_participant/',
                             {'email': email,
                              'name': name,
                              'city': city,
                              'state': state,
                              'zipcode': zipcode,
                              'country': country,
                              'ag_login_id': ag_login_id})
        self.assertEqual(response.code, 400)
        self.assertIn(('MissingArgumentError: HTTP 400: Bad Request '
                       '(Missing argument address)'), response.body)
Exemplo n.º 7
0
    def test_post(self):
        self.mock_login_admin()

        email = "*****@*****.**"
        name = "TESTDUDE"
        address = "123 fake test street"
        city = "testcity"
        state = "\xc3\x8ele-de-France"
        zipcode = "1L2 2G3"
        country = "United Kingdom"
        ag_login_id = "4cc7c201-7301-4088-98b7-8ff6351fd452"

        # check a regular update
        response = self.post(
            "/ag_edit_participant/",
            {
                "email": email,
                "name": name,
                "address": address,
                "city": city,
                "state": state.decode("utf-8"),
                "zipcode": zipcode,
                "country": country,
                "ag_login_id": ag_login_id,
            },
        )
        self.assertEqual(response.code, 200)
        self.assertIn("Participant was updated successfully", response.body)

        # pull it back out and verify
        response = self.get("/ag_edit_participant/?email=%s" % email)
        self.assertEqual(response.code, 200)
        # check that all relevant user information is rendered on HTML side
        login = db.get_login_by_email(email)
        for key, value in login.items():
            if key == "zip":
                key = "zipcode"
            elif key == "ag_login_id":
                continue
            value = value.decode("utf-8")
            self.assertIn(
                ('</td><td><input type="text" name="%s" id="%s" ' 'value="%s"></td></tr>') % (key, key, value),
                response.body.decode("utf-8"),
            )

        # wrong ag_login_id
        response = self.post(
            "/ag_edit_participant/",
            {
                "email": email,
                "name": name,
                "address": address,
                "city": city,
                "state": state.decode("utf-8"),
                "zipcode": zipcode,
                "country": country,
                "ag_login_id": "wrongID",
            },
        )
        self.assertEqual(response.code, 200)
        self.assertIn("Error Updating Particpant Info", response.body)

        # check missing arguments
        response = self.post(
            "/ag_edit_participant/",
            {
                "email": email,
                "name": name,
                "city": city,
                "state": state.decode("utf-8"),
                "zipcode": zipcode,
                "country": country,
                "ag_login_id": ag_login_id,
            },
        )
        self.assertEqual(response.code, 400)
        self.assertIn(("MissingArgumentError: HTTP 400: Bad Request " "(Missing argument address)"), response.body)