From 0a2af2d4fc60f9fa62aefb880c1dd4576e5c8934 Mon Sep 17 00:00:00 2001 From: Angela Tran Date: Mon, 14 Nov 2022 13:22:52 +0000 Subject: [PATCH 1/2] test(init-db): update sample data and test to show failing use case --- data/server.csv | 1 + tests/db/test_setup.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/data/server.csv b/data/server.csv index fe0d2b9e..cfc85ca0 100644 --- a/data/server.csv +++ b/data/server.csv @@ -2,6 +2,7 @@ 32587,Gonzales,courtesy_card 03552,McCulley,courtesy_card 42687,Álvarez,courtesy_card +65149,Álvarez,courtesy_card 89768,Muñoz,courtesy_card 41782,Núñez,courtesy_card 48727,de Merida,courtesy_card diff --git a/tests/db/test_setup.py b/tests/db/test_setup.py index db3507da..cb4f1c7b 100644 --- a/tests/db/test_setup.py +++ b/tests/db/test_setup.py @@ -14,7 +14,7 @@ def test_init_db_command(runner): assert result.exit_code == 0 - assert User.query.count() == 24 + assert User.query.count() == 25 assert Eligibility.query.count() == 1 user_with_one_eligibility = User.query.filter_by(sub="32587", name="Gonzales").first() From b510b8c7bd4665439069343ea12ffd98a8d35668 Mon Sep 17 00:00:00 2001 From: Angela Tran Date: Mon, 14 Nov 2022 13:34:08 +0000 Subject: [PATCH 2/2] fix(init-db): remove unique constraint from User.name --- eligibility_server/db/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eligibility_server/db/models.py b/eligibility_server/db/models.py index 2101e40d..f4d1bf1b 100644 --- a/eligibility_server/db/models.py +++ b/eligibility_server/db/models.py @@ -19,7 +19,7 @@ def __repr__(self): class User(db.Model): id = db.Column(db.Integer, primary_key=True) sub = db.Column(db.String, unique=True, nullable=False) - name = db.Column(db.String, unique=True, nullable=False) + name = db.Column(db.String, unique=False, nullable=False) types = db.relationship("Eligibility", secondary=user_eligibility, lazy="subquery", backref=db.backref("users", lazy=True)) def __repr__(self):