user can update profile
This commit is contained in:
@@ -48,6 +48,17 @@ class UserFactory(Base):
|
||||
last_name = factory.Faker("last_name")
|
||||
atat_role = factory.SubFactory(RoleFactory)
|
||||
dod_id = factory.LazyFunction(lambda: "".join(random.choices(string.digits, k=10)))
|
||||
phone_number = factory.LazyFunction(
|
||||
lambda: "".join(random.choices(string.digits, k=10))
|
||||
)
|
||||
service_branch = factory.LazyFunction(
|
||||
lambda: random.choices([k for k, v in SERVICE_BRANCHES if k is not None])[0]
|
||||
)
|
||||
citizenship = "United States"
|
||||
designation = "military"
|
||||
date_latest_training = factory.LazyFunction(
|
||||
lambda: datetime.date.today() + datetime.timedelta(days=-(random.randrange(1,365)))
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_atat_role(cls, atat_role_name, **kwargs):
|
||||
|
22
tests/routes/test_users.py
Normal file
22
tests/routes/test_users.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from flask import url_for
|
||||
|
||||
from atst.domain.users import Users
|
||||
|
||||
from tests.factories import UserFactory
|
||||
|
||||
def test_user_can_view_profile(user_session, client):
|
||||
user = UserFactory.create()
|
||||
user_session(user)
|
||||
response = client.get(url_for("users.user"))
|
||||
assert user.email in response.data.decode()
|
||||
|
||||
|
||||
def test_user_can_update_profile(user_session, client):
|
||||
user = UserFactory.create()
|
||||
user_session(user)
|
||||
new_data = {**user.to_dictionary(), "first_name": "chad", "last_name": "vader"}
|
||||
new_data["date_latest_training"] = new_data["date_latest_training"].strftime("%m/%d/%Y")
|
||||
client.post(url_for("users.user"), data=new_data)
|
||||
updated_user = Users.get_by_dod_id(user.dod_id)
|
||||
assert updated_user.first_name == "chad"
|
||||
assert updated_user.last_name == "vader"
|
Reference in New Issue
Block a user