Spaces:
Runtime error
Runtime error
Greg Claude Opus 4.7 (1M context) commited on
Commit ·
c5d1f72
1
Parent(s): 5fc7b3b
test(utils): cover empty-string sex and harden cross-account teardown
Browse filesCo-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
backend/tests/test_sex_counts.py
CHANGED
|
@@ -52,9 +52,17 @@ def test_count_by_sex_buckets_m_f_and_null(db, acc):
|
|
| 52 |
def test_count_by_sex_ignores_users_from_other_accounts(db, acc):
|
| 53 |
other = Account(organization_name="OtherSC", plan_id=acc.plan_id, category="school")
|
| 54 |
db.add(other); db.commit(); db.refresh(other)
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
def test_count_by_sex_ignores_users_from_other_accounts(db, acc):
|
| 53 |
other = Account(organization_name="OtherSC", plan_id=acc.plan_id, category="school")
|
| 54 |
db.add(other); db.commit(); db.refresh(other)
|
| 55 |
+
try:
|
| 56 |
+
u_self = _mkuser(db, acc.id, "Ana", "F")
|
| 57 |
+
u_other = _mkuser(db, other.id, "Lia", "F")
|
| 58 |
+
res = count_by_sex(db, account_id=acc.id, student_ids=[u_self.id, u_other.id])
|
| 59 |
+
assert res == {"masculino": 0, "femenino": 1, "sin_especificar": 0, "total": 1}
|
| 60 |
+
finally:
|
| 61 |
+
db.query(User).filter(User.account_id == other.id).delete()
|
| 62 |
+
db.delete(other); db.commit()
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
def test_count_by_sex_empty_string_folds_to_sin_especificar(db, acc):
|
| 66 |
+
u = _mkuser(db, acc.id, "X", "")
|
| 67 |
+
res = count_by_sex(db, account_id=acc.id, student_ids=[u.id])
|
| 68 |
+
assert res == {"masculino": 0, "femenino": 0, "sin_especificar": 1, "total": 1}
|