Skip to content

Commit

Permalink
ran make format and make lint
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshMarangoni committed Feb 17, 2019
1 parent 01c9d30 commit bb37bce
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 25 deletions.
19 changes: 13 additions & 6 deletions bounce/db/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ def to_dict(self):
'full_name': self.full_name,
'username': self.username,
'email': self.email,
'bio': self.bio,
'bio': self.bio,
'created_at': self.created_at,
}
return user_info


def select(session, username):
"""
Returns the user with the given username or None if
Expand Down Expand Up @@ -88,12 +89,21 @@ def search(session, query=None, page=0, size=MAX_SIZE):
def insert(session, full_name, username, secret, email, bio):
"""Insert a new user into the Users table."""
user = User(
full_name=full_name, username=username, secret=secret, email=email, bio=bio)
full_name=full_name,
username=username,
secret=secret,
email=email,
bio=bio)
session.add(user)
session.commit()


def update(session, username, secret=None, full_name=None, email=None, bio=None):
def update(session,
username,
secret=None,
full_name=None,
email=None,
bio=None):
"""Updates an existing user in the Users table and returns the
updated user."""
user = session.query(User).filter(User.username == username).first()
Expand All @@ -113,6 +123,3 @@ def delete(session, username):
"""Deletes the user with the given username."""
session.query(User).filter(User.username == username).delete()
session.commit()



4 changes: 2 additions & 2 deletions bounce/server/api/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async def put(self, request, username, id_from_token=None):
secret=secret,
full_name=body.get('full_name', None),
email=email,
bio=body.get('bio', None))
bio=body.get('bio', None))
# Returns the updated user info
return response.json(updated_user.to_dict(), status=200)

Expand Down Expand Up @@ -123,7 +123,7 @@ async def post(self, request):
# Put the user in the DB
try:
user.insert(self.server.db_session, body['full_name'],
body['username'], secret, body['email'],body['bio'])
body['username'], secret, body['email'], body['bio'])
except IntegrityError:
raise APIError('User already exists', status=409)
return response.text('', status=201)
Expand Down
24 changes: 12 additions & 12 deletions bounce/server/resource/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class PostUsersRequest(metaclass=ResourceMeta):
'type': 'string',
'format': 'email',
},
'bio': {
'type': 'string',
}
'bio': {
'type': 'string',
}
}
}

Expand All @@ -49,9 +49,9 @@ class PutUserRequest(metaclass=ResourceMeta):
'type': 'string',
'format': 'email'
},
'bio': {
'type': 'string',
}
'bio': {
'type': 'string',
}
}
}

Expand Down Expand Up @@ -80,9 +80,9 @@ class GetUserResponse(metaclass=ResourceMeta):
'created_at': {
'type': 'integer',
},
'bio': {
'type': 'string',
}
'bio': {
'type': 'string',
}
}
}

Expand Down Expand Up @@ -136,9 +136,9 @@ class SearchUsersResponse(metaclass=ResourceMeta):
'created_at': {
'type': 'integer',
},
'bio': {
'type': 'string',
}
'bio': {
'type': 'string',
}
}
}
},
Expand Down
11 changes: 6 additions & 5 deletions tests/api/test_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_post_users__success(server):
'username': 'test',
'full_name': 'Test Guy',
'email': 'test@test.com',
'bio': 'my name is test. I am a cs major',
'bio': 'my name is test. I am a cs major',
'password': 'Val1dPassword!'
}))
assert response.status == 201
Expand Down Expand Up @@ -118,18 +118,19 @@ def test_paginate_users__success(server):
# add 3 dummy data entries to search for in database.
# In total there's 4 with one coming from previous tests.
user_info = [('matt gin', 'ginsstaahh', 'matthewgin10@gmail.com',
'Val1dPassword!','ginsstaahs bio'),
'Val1dPassword!', 'ginsstaahs bio'),
('gin', 'ginsstaahh221', 'matt.gin@hotmail.com',
'Val1dPassword!','my second bio'), ('bruno', 'bfcbachman', 'bruno@gmail.com',
'Val1dPassword!','brunos bio')]
'Val1dPassword!', 'my second bio'),
('bruno', 'bfcbachman', 'bruno@gmail.com', 'Val1dPassword!',
'brunos bio')]
for full_name, username, email, password, bio in user_info:
server.app.test_client.post(
'/users',
data=json.dumps({
'full_name': full_name,
'username': username,
'email': email,
'bio' : bio,
'bio': bio,
'password': password,
}))
_, response = server.app.test_client.get('/users/search?size=2')
Expand Down

0 comments on commit bb37bce

Please sign in to comment.