def setUp(self):
        # Delete any test data that may be remained.
        for item in User.scan(User.username.startswith('test')):
            item.delete()
        for item in Photo.scan(Photo.filename_orig.startswith('test')):
            item.delete()

        # Create test user
        test_user = User(uuid.uuid4().hex)
        test_user.email = user['email']
        test_user.username = user['username']
        test_user.password = generate_password_hash(user['password'])
        test_user.save()
예제 #2
0
    def get(self):
        """Get all users as list"""
        try:
            data = []
            for user in User.scan():
                one_user = {
                    'id': user.id,
                    'email': user.email,
                    'username': user.username
                }
                data.append(one_user)

            app.logger.debug('success:users_list: {0}'.format(data))
            return make_response({'ok': True, 'users': data}, 200)
        except Exception as e:
            app.logger.error("users list failed")
            app.logger.error(e)
            raise InternalServerError('Retrieve user list failed')
예제 #3
0
    def get(self):
        """Get all users as list"""
        try:
            data = []

            for user in User.scan():
                one_user = {
                    'id': user.id,
                    'email': user.email,
                    'username': user.username
                }
                data.append(one_user)

            app.logger.debug("success:users_list:%s" % data)
            return m_response(data, 200)

        except Exception as e:
            app.logger.error("users list failed")
            app.logger.error(e)
            return err_response("users list failed", 500)
 def tearDown(self):
     # Delete test data
     for item in User.scan(User.username.startswith('test')):
         item.delete()
     for item in Photo.scan(Photo.filename_orig.startswith('test')):
         item.delete()