Esempio n. 1
0
    def test_get_group_members(self):
        user = self._sample_user()
        group = self._sample_group(user)

        with self.app_context:
            Group.remove(group.id)
            User.remove(user.id)

            user.save()
            group.save()

            ret = []

            for friend_id in group.users:
                friend = User.get_by_id(friend_id)
                ret.extend([{
                    'friend_id': friend_id,
                    'name': friend.email,
                    'location': friend.location
                }])

            self.assertGreater(len(ret), 0)

            Group.remove(group.id)
            User.remove(user.id)
Esempio n. 2
0
    def test_update_user_location(self):
        user = self._sample_user()

        with self.app_context:
            user.save()

            User.update_location(user.id, 57.062, 13.673)

            user_test = User.get_by_id(user.id)
            self.assertEqual(user_test.location[0], 57.062)
            self.assertEqual(user_test.location[1], 13.673)
            User.remove(user.id)
Esempio n. 3
0
    def test_register_user(self):
        with self.app_context:
            user = User.register(email="*****@*****.**", password="******")

            user.save()

            user_test = User.get_by_id(user.id)
            self.assertIsNotNone(user_test.access_token)
            self.assertEqual(user.email, "*****@*****.**")
            self.assertTrue(check_password_hash(user.password, "paco"))

            User.remove(user.id)
def get_friend_locations(group_id):
    group = Group.get_by_id(group_id)

    ret = []

    for friend_id in group.users:
        ret.extend([User.get_by_id(friend_id).to_dict()])

    response_data = create_response_data(
        {'friends': ret},
        200
    )
    return jsonify(response_data), response_data['status_code']
Esempio n. 5
0
def confirm(token):
    log("Starting confirmation...")
    invite = Invite.get_by_token(token)
    log("Inviter ID: {}".format(invite.inviter_id))
    inviter = User.get_by_id(invite.inviter_id)
    log("Invited by: {}".format(inviter.email))

    try:
        return render_template('invite.html',
                               email=invite.email,
                               token=token,
                               inviter_email=inviter.email), 200
    except jinja2.TemplateNotFound:
        response_data = Utils.create_response_error(
            "InternalServerError", "The server could not display the template",
            500)
        return jsonify(response_data), response_data['status_code']
def confirm(token):
    log("Starting confirmation...")
    invite = Invite.get_by_token(token)
    log("Inviter ID: {}".format(invite.inviter_id))
    inviter = User.get_by_id(invite.inviter_id)
    log("Invited by: {}".format(inviter.email))

    try:
        return render_template('invite.html',
                               email=invite.email,
                               token=token,
                               inviter_email=inviter.email), 200
    except Exception:
        type, ex, trace = sys.exc_info()
        loggerObject.error(path + " | " + os.path.join(path, '../../app/templates/'))
        loggerObject.error(type)
        loggerObject.error(ex.message)
        response_data = create_response_error(
            "InternalServerError",
            "The server could not display the template",
            500
        )
        return jsonify(response_data), response_data['status_code']