Ejemplo n.º 1
0
 def create(self,user):
     country = Country.get_by_id(user.country)
     if not country:
         raise endpoints.NotFoundException(
         "Error: Country assigned to user does not exist"
         )
     entity = User(
         name=user.name,
         parent=ndb.Key("Country",user.country),
     )
     key = entity.put()
     user.id = key.id()
     return user
Ejemplo n.º 2
0
class TesteUserModel(TestCase):
    data = {
        "login": "******",
        "password": "******",
        "city": "Curitiba"
    }

    new_login = "******"
    new_password = "******"
    new_city = "São paulo"

    users = Users()
    user = User()
    user_register = UserRegister()
    user_update = UserUpdate()
    user_login = UserLogin()

    @app.route('/users')
    def test_list_users(self):
        assert self.users.get()

    with app.test_client() as client:
        response = client.get('/users')
        data = json.load(response.data)
        print
class TesteUserModel(TestCase):
    data = {
        "login": "******",
        "password": "******",
        "city": "Curitiba"
    }

    new_login = "******"
    new_password = "******"
    new_city = "São paulo"

    users = Users()
    user = User()
    user_register = UserRegister()
    user_update = UserUpdate()
    user_login = UserLogin()

    #     @app.route('/users')
    #     def test_list_users():
    #         print('test')
    #         # assert self.users.get()

    # # if __name__ == '__main__':
    # with app.test_client() as client:
    #     client.get('/users')@app.route('/')
    def hello():
        print('during view')
        return 'Hello, World!'

    @app.teardown_request
    def show_teardown(exception):
        print('after with block')
Ejemplo n.º 4
0
    def delete(self, user):
        entity = User.get_by_id(user.id)
        if not entity:
            raise endpoints.BadRequestException(
            "Error: This user is not registered in our system"
            )

        entity.key.delete()
        return message_types.VoidMessage();
class TesteUserModel(TestCase):
    data = {
        "login": "******",
        "password": "******",
        "city": "Curitiba"
    }

    new_login = "******"
    new_password = "******"
    new_city = "São paulo"

    users = Users()
    user = User()
    user_register = UserRegister()
    user_update = UserUpdate()
    user_login = UserLogin()

    @app.route('/users')
    def test_list_users(self):
Ejemplo n.º 6
0
 def items_list(self,query):
     country = Country.get_by_id(user.country)
     if not country:
         raise endpoints.NotFoundException(
         "Error: Country searched does not exist "
         )
     parent = None
     if query.country:
         parent = ndb.Key("Country",query.country)
     entities = User.query(ancestor=parent).fetch()
     apiUserList = []
     for item in entities:
         apiUserList.append(ApiUser(
         name=item.name,
         country=item.key.parent().id(),
         id=item.key.id(),
         ))
     return ApiUsers(
     users=apiUserList
     )
Ejemplo n.º 7
0
def authenticate(username, password):
    user = User.find_by_username(username)
    if user and safe_str_cmp(user.password, password):
        return user
Ejemplo n.º 8
0
def identity(payload):
    user_id = payload['identity']
    return User.find_by_id(user_id)
Ejemplo n.º 9
0
def identity(payload):
    userid = payload["identity"]
    return User.find_by_id(userid)
Ejemplo n.º 10
0
def authenticate(username, password):
    user = User.find_by_username(username)
    if user and password == user.password:  #OR if user is not None OR if user != None
        return user