Add student SGU profile synchronization

This commit is contained in:
2026-09-01 14:23:20 -06:00
parent 3b5cf723cc
commit fd3eb537a1
21 changed files with 345 additions and 43 deletions
@@ -56,6 +56,97 @@ public sealed class SguProfileParserTests
Assert.Null(SguProfileParser.ParseAdministrative(html, "999999"));
}
[Fact]
public void ParsesTheRequiredStudentIdentityCareerAndAddressFields()
{
const string html = """
<html><body>
<div id="ctl00_contenedor_HistorialAlumno1_div1">
<span id="ctl00_contenedor_HistorialAlumno1_lblClaveAlumnoHP">123456</span>
<span id="ctl00_contenedor_HistorialAlumno1_lblNombreAlumnoHP">MARÍA DEL CARMEN</span>
<span id="ctl00_contenedor_HistorialAlumno1_lblApPatAlumnoHP">DE LA FUENTE</span>
<span id="ctl00_contenedor_HistorialAlumno1_lblApMatAlumnoHP">O'CONNOR</span>
<span id="ctl00_contenedor_HistorialAlumno1_lblCorreoAlumnoHP">
<a href="mailto:alumna@lasalle.mx">ALUMNA@LASALLE.MX</a>
</span>
<span id="ctl00_contenedor_HistorialAlumno1_lblCURPAlumnoHP">
DATO-SENSIBLE-QUE-NO-DEBE-EXTRAERSE
</span>
</div>
<span id="ctl00_contenedor_HistorialAlumno1_Header1_lblCarrera">
LICENCIATURA EN INGENIERÍA CIBERNÉTICA Y SISTEMAS COMPUTACIO NALES
</span>
<div id="ctl00_contenedor_HistorialAlumno1_div2">
<span id="ctl00_contenedor_HistorialAlumno1_lblDomicilioAlumnoHP">
AVENIDA DE LA UNIVERSIDAD 123
</span>
<span id="ctl00_contenedor_HistorialAlumno1_lblColoniaAlumnoHP">
COLONIA DEL VALLE
</span>
<span id="ctl00_contenedor_HistorialAlumno1_lblEstadoAlumnoHP">
CIUDAD DE MÉXICO
</span>
<span id="ctl00_contenedor_HistorialAlumno1_lblCiudadAlumnoHP">
CIUDAD DE MÉXICO
</span>
<span id="ctl00_contenedor_HistorialAlumno1_lblDeloMunAlumnoHP">
ALCALDÍA BENITO JUÁREZ
</span>
<span id="ctl00_contenedor_HistorialAlumno1_lblCPAlumnoHP">8500</span>
</div>
</body></html>
""";
InstitutionalProfile? profile = SguProfileParser.ParseStudent(html, "123456");
Assert.NotNull(profile);
Assert.Equal("123456", profile.EmployeeNumber);
Assert.Equal("María del Carmen de la Fuente O'Connor", profile.DisplayName);
Assert.Equal("María del Carmen", profile.GivenName);
Assert.Equal("de la Fuente O'Connor", profile.Surname);
Assert.Equal("alumna@lasalle.mx", profile.Email);
Assert.Equal("Alumno", profile.EmployeeType);
Assert.Equal(
"Estudiante de Ingeniería Cibernética y Sistemas Computacionales",
profile.JobTitle);
Assert.Null(profile.Department);
Assert.Equal(
"Avenida de la Universidad 123\r\nColonia del Valle\r\nAlcaldía Benito Juárez",
profile.StreetAddress);
Assert.Equal("Ciudad de México", profile.City);
Assert.Equal("Ciudad de México", profile.State);
Assert.Equal("08500", profile.PostalCode);
}
[Fact]
public void RejectsStudentMetadataForADifferentStudentNumber()
{
const string html = """
<span id="ctl00_contenedor_HistorialAlumno1_lblClaveAlumnoHP">123456</span>
<span id="ctl00_contenedor_HistorialAlumno1_lblNombreAlumnoHP">PERSONA INCORRECTA</span>
<span id="ctl00_contenedor_HistorialAlumno1_lblCorreoAlumnoHP">incorrecta@lasalle.mx</span>
""";
Assert.Null(SguProfileParser.ParseStudent(html, "654321"));
}
[Fact]
public void UsesMunicipalityAsStudentCityWhenThePortalCityIsMissing()
{
const string html = """
<span id="ctl00_contenedor_HistorialAlumno1_lblClaveAlumnoHP">123456</span>
<span id="ctl00_contenedor_HistorialAlumno1_lblDeloMunAlumnoHP">SAN PEDRO CHOLULA</span>
<span id="ctl00_contenedor_HistorialAlumno1_lblCPAlumnoHP">72760</span>
""";
InstitutionalProfile? profile = SguProfileParser.ParseStudent(html, "123456");
Assert.NotNull(profile);
Assert.Equal("San Pedro Cholula", profile.City);
Assert.Equal("San Pedro Cholula", profile.StreetAddress);
Assert.Equal("72760", profile.PostalCode);
}
[Fact]
public void ParsesTheMenuNameAsAConservativeFallback()
{