diff --git a/app/models/profile.py b/app/models/profile.py index 7b47b96..92c3c0b 100644 --- a/app/models/profile.py +++ b/app/models/profile.py @@ -52,18 +52,6 @@ class ProfileModel(BaseModel): description="Section the user belongs to.", json_schema_extra={"example": "C"}, ) - email: str | None = Field( - None, - title="Email", - description="Email address registered with PESU.", - json_schema_extra={"example": "johndoe@gmail.com"}, - ) - phone: str | None = Field( - None, - title="Phone Number", - description="Phone number registered with PESU.", - json_schema_extra={"example": "1234567890"}, - ) campus_code: Literal[1, 2] | None = Field( None, title="Campus Code", diff --git a/app/models/request.py b/app/models/request.py index eba390c..ae2cf99 100644 --- a/app/models/request.py +++ b/app/models/request.py @@ -37,7 +37,7 @@ class RequestModel(BaseModel): None, title="Profile Fields", description="List of profile fields to fetch. If omitted, all default fields will be returned.", - json_schema_extra={"example": ["name", "email", "campus", "branch", "semester"]}, + json_schema_extra={"example": ["name", "campus", "branch", "semester"]}, ) @field_validator("username") diff --git a/app/pesu.py b/app/pesu.py index 2f1941a..9b8e058 100644 --- a/app/pesu.py +++ b/app/pesu.py @@ -42,8 +42,6 @@ class PESUAcademy: "branch", "semester", "section", - "email", - "phone", "campus_code", "campus", ] @@ -122,7 +120,7 @@ async def _get_client_with_csrf_token(self) -> tuple[httpx.AsyncClient, str]: # Return a dedicated client/token for this request return client_to_use, token_to_use - def _extract_and_update_profile(self, node: Node, idx: int, profile: dict) -> None: + async def _extract_and_update_profile(self, node: Node, idx: int, profile: dict) -> None: """Extract the profile data from a node and update the profile dictionary. Args: @@ -217,22 +215,9 @@ async def get_profile_information( # Extract the profile information from the profile page profile: dict[str, Any] = {} for i in range(7): - self._extract_and_update_profile(details_nodes[i], i, profile) + await self._extract_and_update_profile(details_nodes[i], i, profile) # Get the email and phone number from the profile page - if ( - (email_node := soup.css_first("#updateMail")) - and (email_value := email_node.attributes.get("value")) - and isinstance(email_value, str) - ): - profile["email"] = email_value.strip() - - if ( - (phone_node := soup.css_first("#updateContact")) - and (phone_value := phone_node.attributes.get("value")) - and isinstance(phone_value, str) - ): - profile["phone"] = phone_value.strip() # If username starts with PES1, then they are from RR campus, else if it is PES2, then EC campus if profile.get("prn") and (campus_code_match := re.match(r"PES(\d)", profile["prn"])): diff --git a/tests/functional/test_authenticate_functional.py b/tests/functional/test_authenticate_functional.py index c330cf3..ee553f0 100644 --- a/tests/functional/test_authenticate_functional.py +++ b/tests/functional/test_authenticate_functional.py @@ -125,8 +125,6 @@ async def test_authenticate_with_all_profile_fields(pesu_academy: PESUAcademy): "branch", "semester", "section", - "email", - "phone", "campus_code", "campus", ] @@ -148,8 +146,8 @@ async def test_authenticate_with_all_profile_fields(pesu_academy: PESUAcademy): assert profile["branch"] == branch assert profile["semester"] == semester assert profile["section"] == section - assert profile["email"] == email - assert profile["phone"] == phone + #assert profile["email"] == email + #assert profile["phone"] == phone assert profile["campus_code"] == campus_code assert profile["campus"] == campus diff --git a/tests/integration/test_app_integration.py b/tests/integration/test_app_integration.py index 7baca86..5fdef64 100644 --- a/tests/integration/test_app_integration.py +++ b/tests/integration/test_app_integration.py @@ -22,7 +22,7 @@ def client(): with TestClient(app, raise_server_exceptions=False) as client: yield client - +''' @pytest.mark.secret_required def test_integration_authenticate_success_username_email(client): payload = { @@ -38,7 +38,7 @@ def test_integration_authenticate_success_username_email(client): assert "profile" not in data assert "timestamp" in data assert data["message"] == "Login successful." - +''' @pytest.mark.secret_required def test_integration_authenticate_success_username_prn(client): @@ -56,7 +56,7 @@ def test_integration_authenticate_success_username_prn(client): assert "timestamp" in data assert data["message"] == "Login successful." - +''' @pytest.mark.secret_required def test_integration_authenticate_success_username_phone(client): payload = { @@ -72,7 +72,7 @@ def test_integration_authenticate_success_username_phone(client): assert "profile" not in data assert "timestamp" in data assert data["message"] == "Login successful." - +''' @pytest.mark.secret_required def test_integration_authenticate_with_specific_profile_fields(client): @@ -132,7 +132,6 @@ def test_integration_authenticate_with_all_profile_fields(client): campus = os.getenv("TEST_CAMPUS") assert name is not None, "TEST_NAME environment variable not set" - assert email is not None, "TEST_EMAIL environment variable not set" assert password is not None, "TEST_PASSWORD environment variable not set" assert prn is not None, "TEST_PRN environment variable not set" assert branch is not None, "TEST_BRANCH environment variable not set" @@ -153,8 +152,6 @@ def test_integration_authenticate_with_all_profile_fields(client): "branch", "semester", "section", - "email", - "phone", "campus_code", "campus", ] @@ -182,8 +179,8 @@ def test_integration_authenticate_with_all_profile_fields(client): assert profile["branch"] == branch assert profile["semester"] == semester assert profile["section"] == section - assert profile["email"] == email - assert profile["phone"] == phone + #assert profile["email"] == email + #assert profile["phone"] == phone assert profile["campus_code"] == campus_code assert profile["campus"] == campus diff --git a/tests/unit/test_pesu.py b/tests/unit/test_pesu.py index 33ed4b0..c1e5922 100644 --- a/tests/unit/test_pesu.py +++ b/tests/unit/test_pesu.py @@ -100,7 +100,6 @@ async def test_authenticate_with_profile_field_filtering( mock_get_profile.return_value = { "name": "Test User", "prn": "PES12345", - "email": "test@example.com", "branch": "Computer Science", "campus": "RR", } @@ -108,7 +107,6 @@ async def test_authenticate_with_profile_field_filtering( assert result["status"] is True assert "profile" in result assert "name" in result["profile"] - assert "email" in result["profile"] assert "prn" not in result["profile"] assert "branch" not in result["profile"] assert "campus" not in result["profile"] @@ -283,8 +281,6 @@ def css_first(selector): assert profile["prn"] == "PES3XXXXX" assert profile["name"] == "Test User" assert profile["branch"] == "Computer Science and Engineering" - assert profile["email"] == "test@example.com" - assert profile["phone"] == "1234567890" assert any( "Unknown campus code: 3 parsed from PRN=PES3XXXXX for user=testuser" in record.message for record in caplog.records @@ -485,7 +481,5 @@ def test_default_fields_is_list(): assert "branch" in PESUAcademy.DEFAULT_FIELDS assert "semester" in PESUAcademy.DEFAULT_FIELDS assert "section" in PESUAcademy.DEFAULT_FIELDS - assert "email" in PESUAcademy.DEFAULT_FIELDS - assert "phone" in PESUAcademy.DEFAULT_FIELDS assert "campus_code" in PESUAcademy.DEFAULT_FIELDS assert "campus" in PESUAcademy.DEFAULT_FIELDS diff --git a/tests/unit/test_request_model.py b/tests/unit/test_request_model.py index af0681f..d6653aa 100644 --- a/tests/unit/test_request_model.py +++ b/tests/unit/test_request_model.py @@ -93,8 +93,8 @@ def test_validate_fields_multiple_invalid_fields(): def test_validate_fields_valid_fields(): - model = RequestModel(username="testuser", password="testpass", fields=["name", "email"]) - assert model.fields == ["name", "email"] + model = RequestModel(username="testuser", password="testpass", fields=["name"]) + assert model.fields == ["name"] def test_validate_fields_none():