diff --git a/gratipay/models/participant/__init__.py b/gratipay/models/participant/__init__.py index 6158e000ef..04f7d81ff2 100644 --- a/gratipay/models/participant/__init__.py +++ b/gratipay/models/participant/__init__.py @@ -1198,7 +1198,7 @@ class BalanceIsNotZero(Exception): pass def final_check(self, cursor): """Sanity-check that teams and balance have been dealt with. """ - if self.get_teams(cursor=cursor): + if self.get_teams(cursor=cursor, only_open=True): raise self.StillOnATeam if self.balance != 0: raise self.BalanceIsNotZero diff --git a/tests/py/test_close.py b/tests/py/test_close.py index e70dcb3b7f..dd6dce3e60 100644 --- a/tests/py/test_close.py +++ b/tests/py/test_close.py @@ -31,6 +31,12 @@ def test_close_fails_if_still_owns_a_team(self): with pytest.raises(alice.StillOnATeam): alice.close() + def test_close_succeeds_if_team_is_closed(self): + alice = self.make_participant('alice', claimed_time='now') + self.make_team(owner=alice, is_closed=True) + alice.close() + assert P('alice').is_closed + def test_close_page_is_usually_available(self): self.make_participant('alice', claimed_time='now') body = self.client.GET('/~alice/settings/close', auth_as='alice').body