From 441f534c941fd4836d1a822b731e993d01a7d67d Mon Sep 17 00:00:00 2001 From: root Date: Wed, 4 Dec 2024 09:09:22 -0500 Subject: [PATCH 1/2] change files --- tests/conftest.py | 31 ++++++++++++++++++++----- tests/test_schemas/test_user_schemas.py | 2 +- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 6bd7998ac..a96dd6874 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -82,6 +82,15 @@ async def setup_database(): await conn.run_sync(Base.metadata.drop_all) await engine.dispose() +from app.services.jwt_service import create_access_token +import pytest + +@pytest.fixture(scope="function") +async def admin_token(admin_user, db_session): + """Fixture to generate an authentication token for the admin user.""" + token = create_access_token(user_id=str(admin_user.id), role=admin_user.role) + return token + @pytest.fixture(scope="function") async def db_session(setup_database): async with AsyncSessionScoped() as session: @@ -195,6 +204,8 @@ async def admin_user(db_session: AsyncSession): await db_session.commit() return user + + @pytest.fixture async def manager_user(db_session: AsyncSession): user = User( @@ -219,7 +230,8 @@ def user_base_data(): "email": "john.doe@example.com", "full_name": "John Doe", "bio": "I am a software engineer with over 5 years of experience.", - "profile_picture_url": "https://example.com/profile_pictures/john_doe.jpg" + "profile_picture_url": "https://example.com/profile_pictures/john_doe.jpg", + "nickname": "John" } @pytest.fixture @@ -229,13 +241,14 @@ def user_base_data_invalid(): "email": "john.doe.example.com", "full_name": "John Doe", "bio": "I am a software engineer with over 5 years of experience.", - "profile_picture_url": "https://example.com/profile_pictures/john_doe.jpg" + "profile_picture_url": "https://example.com/profile_pictures/john_doe.jpg", + "nickname": "John" } @pytest.fixture def user_create_data(user_base_data): - return {**user_base_data, "password": "SecurePassword123!"} + return {**user_base_data, "password": "SecurePassword123!", "nickname": "Doe"} @pytest.fixture def user_update_data(): @@ -243,13 +256,19 @@ def user_update_data(): "email": "john.doe.new@example.com", "full_name": "John H. Doe", "bio": "I specialize in backend development with Python and Node.js.", - "profile_picture_url": "https://example.com/profile_pictures/john_doe_updated.jpg" + "profile_picture_url": "https://example.com/profile_pictures/john_doe_updated.jpg", + "first_name": "John" } +import uuid +import pytest +from datetime import datetime + + @pytest.fixture def user_response_data(): return { - "id": "unique-id-string", + "id": str(uuid.uuid4()), #unique-id-string "username": "testuser", "email": "test@example.com", "last_login_at": datetime.now(), @@ -260,4 +279,4 @@ def user_response_data(): @pytest.fixture def login_request_data(): - return {"username": "john_doe_123", "password": "SecurePassword123!"} \ No newline at end of file + return {"username": "john_doe_123", "password": "SecurePassword123!", "email": "johndoe@example.com"} \ No newline at end of file diff --git a/tests/test_schemas/test_user_schemas.py b/tests/test_schemas/test_user_schemas.py index c5b92e148..4a01f7b07 100644 --- a/tests/test_schemas/test_user_schemas.py +++ b/tests/test_schemas/test_user_schemas.py @@ -25,7 +25,7 @@ def test_user_update_valid(user_update_data): # Tests for UserResponse def test_user_response_valid(user_response_data): user = UserResponse(**user_response_data) - assert user.id == user_response_data["id"] + assert str(user.id) == user_response_data["id"] # assert user.last_login_at == user_response_data["last_login_at"] # Tests for LoginRequest From ef5e6744c748f62906b69202a523cf16f57074cc Mon Sep 17 00:00:00 2001 From: root Date: Thu, 5 Dec 2024 17:16:55 -0500 Subject: [PATCH 2/2] change files --- Reflection | 3 +++ Xavier S. HW10 reflection.pdf:Zone.Identifier | 4 ++++ 2 files changed, 7 insertions(+) create mode 100644 Reflection create mode 100644 Xavier S. HW10 reflection.pdf:Zone.Identifier diff --git a/Reflection b/Reflection new file mode 100644 index 000000000..496248890 --- /dev/null +++ b/Reflection @@ -0,0 +1,3 @@ +I had a lot of difficulty with this hw assignment, this was probably the trickiest assignment I’ve had bya far if I'm being honest. I watched the instructor video but it was still a little hard to follow. I might just have to go back and rewatch it again. I couldn't figure out the issue demonstrated in the instructor video, however I was able to resolve 5 issues related to key and assertion errors related to the nickname and username related to the project. + +However, I could definitely still use a little more practice. Creating and documenting issues wasn’t difficult and was probably one of the easier parts of the project. I can also get some more practice on the openapi and the type of code errors. diff --git a/Xavier S. HW10 reflection.pdf:Zone.Identifier b/Xavier S. HW10 reflection.pdf:Zone.Identifier new file mode 100644 index 000000000..dc291da11 --- /dev/null +++ b/Xavier S. HW10 reflection.pdf:Zone.Identifier @@ -0,0 +1,4 @@ +[ZoneTransfer] +ZoneId=3 +ReferrerUrl=https://docs.google.com/ +HostUrl=https://doc-04-a0-docstext.googleusercontent.com/export/voi4ak7u127vqdc9isekn6kb18/f07e8j4dr3uf0c8a1qill094dk/1733436910000/103053751051553476807/103053751051553476807/1sKFiY4AGIExgHraYCaj90U76ZrYiN7rPwxhUXWNyBv8?format=pdf&id=1sKFiY4AGIExgHraYCaj90U76ZrYiN7rPwxhUXWNyBv8&token=AC4w5VgogHFS7eh4chZkQx6chNTL5cKzSQ:1733363929803&includes_info_params=true&usp=drive_web&cros_files=false&tab=t.0&inspectorResult=%7B%22pc%22:1,%22lplc%22:9%7D&dat=AOBvIb2jNLETljqep-pDvjSXoYZwmBQgQkQ0vU-7FoQLoSBN_Az0P_hvXHTcgx3hQwPXwkWI02WiMSwYpAYUGT4wdtjBpCYgLUFaBXZVATiej21Bpmr9VbQkzkOno-xpBUa6aecNUCjoGl4rfJls9KCiM0Ql6J6rBm_-u03yQaVBDpDJjMad5N4RvQ2lxySaRJp9U4LeCKC6Su_J-uETmiRDQKQxee7Lteo38Wo_e2hOsIF1xRUWwh0ItFIOhTdz1fvAS-iZpQVgkSv9gFjvsPZAbq1oJ97z_tjTt9Q7IiuWKvdSLOY_D8ZLLD2AUy4PPEaulmcviT-bSb5OTXAyFWszrcIKaKAYp907kP-3fHObCpC9x6g7qd-JrXhr4o67cT2gk0wrA9N-8UilPT-Yuntv5jjRWsykeZMWwRR0RdJf2x039O-ISwNFLh8_oJ3Ai0kGnJ-iBOwJ8eYAr1T-873dZybF4k2oFYCqT-w8ugfGcxIOUmQ1uFIN1XhK54cQ3MnxExOLCx98PY0SCkWdwcFwHb1T-vsFm2T2m59SJ0MOp0xEvZZ8C8XyBEKgQeX-q3q2DY3LY6EvXo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