user can update profile

This commit is contained in:
dandds
2018-10-15 15:30:15 -04:00
parent ec7504fb20
commit f3c3332127
4 changed files with 45 additions and 3 deletions

View File

@@ -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):

View 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"