diff --git a/gratipay/utils/fake_data.py b/gratipay/utils/fake_data.py index a0400ec479..7a33d62621 100644 --- a/gratipay/utils/fake_data.py +++ b/gratipay/utils/fake_data.py @@ -15,6 +15,7 @@ from gratipay.models.team import slugize, Team from gratipay.models import community from gratipay.models import check_db +from gratipay.exceptions import InvalidTeamName faker = Factory.create() @@ -141,7 +142,7 @@ def fake_team(db, teamowner, teamname=None): , receiving=0.1 , nreceiving_from=3 ) - except IntegrityError: + except (IntegrityError, InvalidTeamName): return fake_team(db, teamowner) return Team.from_slug(teamslug) diff --git a/tests/py/test_fake_data.py b/tests/py/test_fake_data.py index feb6168a79..c39d2845c8 100644 --- a/tests/py/test_fake_data.py +++ b/tests/py/test_fake_data.py @@ -34,3 +34,8 @@ def test_fake_participant_identity(self): crusher = self.make_participant('crusher', email_address='crusher@example.com') country_id = fake_data.fake_participant_identity(crusher) assert [x.country.id for x in crusher.list_identity_metadata()] == [country_id] + + def test_fake_team_doesnt_fail_for_name_with_apostrophe(self): + crusher = self.make_participant('crusher', email_address='crusher@example.com') + team = fake_data.fake_team(self.db, crusher, "D'Amorebury") + assert team.name != "d-amorebury"